URL.getContent() method

When I get the class name of the object I'm getting back from the call to URL.getContent(), the object's class name is:
sun.net.www.protocol.http.HttpURLConnection$HttpInputStream
I originally just ignored the part after the $ character, and just assumed it was a:
sun.net.www.protocol.http.HttpURLConnection
object, but a class cast exception is thrown when I try to cast this object to java.net.HttpURLConnection (which extends:
sun.net.www.protocol.http.HttpURLConnection
Does $ followed by the HttpInputStream indicate that HttpInputStream is an inner class of:
sun.net.www.protocol.http.HttpURLConnection
Could someone tell me how to use this object that is being returned to me.
Thanks,
Tim

You can cast it to an InputStream. Here is a complete program that will read a file from the specified url:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.HttpURLConnection;
public class URLTester
     private final static String PROTOCOL = "http://";
     public static void main(String args[])
          if ( args.length != 1 )
               System.out.println("Usage: java URLTester <url>");
               System.exit(-1);
          String urlString = args[0];
          try
               URL url = new URL(PROTOCOL + urlString);
               InputStream is = (InputStream)url.getContent();
               InputStreamReader isr = new InputStreamReader( is );
               BufferedReader in = new BufferedReader( isr );
               String line;
               while ( (line = in.readLine() ) != null )
                    System.out.println( line );
               in.close();
          catch(IOException e)
               System.out.println( e );

Similar Messages

  • Horizontal scroll bar disappears in URL isolation method iview

    Hello Experts,
    I am facing a strange problem. In MSS --> Reporting, when the report is generated, it is shown in a new window. That iview is basically having URL isolation method which has been disabled i.e. it cannot be changed(It is an iview created by SAP). The problem is the scroll bars. The report is basically a R3 report which has scroll bars but when it is displayed in the iview, the horizontal scroll bar disappears.
    The requirement is to have both the scroll bars.
    The horizontal scroll bar appears for a while when we manually resize the window.
    I have checked the windows parameters also in which the scroll bars are set to 1 through code in WD java(not in the iview properties).
    Please help !!
    Thanks & Regards
    Vikash
    Edited by: modish on Jan 25, 2012 8:00 AM

    Vikash,
    Header and footer can be handled from the property 'tray' of the page and iview. But this is not a matter of concern. Try the following to see if the report is getting generated-
    1) Try toying with the properties of page- 'authentication scheme', 'initial state-open', 'isolation method-embedded','metadata for navigation hierarchy-cacheable'.
    If the above do not help-
    1) Preview your iView from the admin console.
    2) Right click on the opened up window (where the report is getting displayed) and select properties.
    3) Copy the address URL from that.
    4) Create a URL iView for the above copied URL
    5) Use this new iView to see if it resolves your problem. OR assign this to a page and then see it that helps.
    Its really strange to believe the above, but it actually helped me in one scenario. Let's give it a try and then I can explain further its reasoning.
    Regards,
    Atul

  • How to use getContent() method in custom JSP Provider to display a HTML Pag

    Hi,
    If anybody knows how to use getContent() method to use in custom jsp providers (developed by ourselves) so that it can be used to retrieve a jsp page (a simple html page) ..
    I want the code in the provider java file to for the getContent method...
    Pls. get back to me asap....if any body has implemented a custom jsp provider...as it's urgent...
    I have alreday placed the JSP file in the directory structure /etc/opt/SUNWps/desktop/default/channel_dir..But still the jsp is not being displayed..
    Pls get me the getContent() method code to retrive the JSP file..
    satyabrata

    Hi,
    You don't have to do anything in the custom JSPProvider's getContent method except the call {  return super.getContent(request,response); } . If all you want is just to show your jsp, then create a channel from the default JSPProvider, and edit the property contentPage of that channel from samplecontent.jsp to your jsp name, save the changes and login again. You should see your JSP.
    Sanjeev.

  • No such method found for com.sun.jndi.toolkit.url.UrlUtil: method

    Hello,
    I have a servlet which allow users to authenticate to IPlanet LDAP server. I have no problem to access it when it runs under a standalone Tomcate server but I have an internal error when it runs under Oracle8i server.
    The following error message was found in mod_serv.log file in \%OracleHome%\Apache\Jserv\logs folder:
    ajp12: Servlet Error: java.lang.NoSuchMethodError: com.sun.jndi.toolkit.url.UrlUtil: method decode(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; not found: com.sun.jndi.toolkit.url.UrlUtil: method decode(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; not found.
    What is the problem? Where should I put my jndi.jar? Thanks.
    Regards
    CY Seah

    Hello,
    I have a servlet which allow users to authenticate to IPlanet LDAP server. I have no problem to access it when it runs under a standalone Tomcate server but I have an internal error when it runs under Oracle8i server.
    The following error message was found in mod_serv.log file in \%OracleHome%\Apache\Jserv\logs folder:
    ajp12: Servlet Error: java.lang.NoSuchMethodError: com.sun.jndi.toolkit.url.UrlUtil: method decode(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; not found: com.sun.jndi.toolkit.url.UrlUtil: method decode(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; not found.
    What is the problem? Where should I put my jndi.jar? Thanks.
    Regards
    CY Seah

  • URL Isolation Method for iViews

    Hi All,
    I am using EP 6.0, and in one of the Pages I have included 3 iViews. Since the operations of these 3 iViews are mostly independent and does not require an entire Page to re-loaded I have made the Isolation method for all the 3 iViews as URL Isolation.
    Now the problem is whenever there is a call to the entire page, the contents are loaded based on the input parameters which comes as a part of Request Object. The page passes on the Request paramter to the iViews. But for URL Isolation, the request paramater does not contain any of the parameters that are set.
    If the Isolation method is set to Embedded Iviews, all the three iViews get the same request object, unlike in the URL Isolation. Also in this case the request parameters passed to the page are available in the iviews.
    My query is :-
    Is there a way I can pass the input parameters to all the 3 iViews, when the whole page is loaded.
    Thanks
    Ankur

    Hi Ankur, check this topic at sap help
    http://help.sap.com/saphelp_nw70/helpdata/en/b5/8d977463334342be192228d2824fe1/content.htm
    “Parameters to Pass from Page Request” Property
    An iView that is set to the URL isolation method is isolated from the page request and does not automatically receive the parameters from the page request.
    The Parameters to Pass from Page Request property lets you define a set of URL-based parameters that should be forwarded from a portal page request to the iFrame displaying the current iView.
    Use this property to define page request parameters as follows:
    Property Value
    Description
    Asterisk (*)
    Passes all parameters
    Empty field
    Does not pass any parameters
    Asterisk, comma and parameters separated by a comma (*,param1,param2)
    Passes all parameters except for those listed.
    Parameters separated by a comma (param1,param2)
    Passes the listed parameters.

  • Java.lang.ClassCastException by url.getContent()

    Hello,
    my sample code out of my learning book don't works and i can't fix it. The code sould read a webpage and print it to the console. But i get an error by running the class. The code and the error are below. The archives has similar postings but know clear solution (for me) for it.
    import java.net.*;
    import java.io.*;
    public class Snatch {
         public static void main(String[] arg) {
              int character;
              BufferedInputStream bin;
              try {
                   URL url = new URL("http://www.google.de/index.html");
                   bin = (BufferedInputStream)url.getContent();
                   while((character = bin.read()) >0)
                        System.out.print((char)character);
                        System.out.println();
                   } catch(MalformedURLException e) {
                        System.out.println(e);
                   } catch(IOException e) {
                        System.out.println(e);
    }error runtime inviroment:
    C:\Vogtmann\java\aewcode\network>java Snatch
    java.lang.ClassCastException: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream
         at Snatch.main(Snatch.java:9)
    Exception in thread "main"
    C:\Vogtmann\java\aewcode\network>
    Thanks for any help
    Richard

    hello,
    it seems as i fied the problem, but my duke dollors are gone. Here ist the working code.
    import java.net.*;
    import java.io.*;
    public class Snatch {
         public static void main(String[] arg) {
              int character;
              InputStream bin;
              try {
                   URL url = new URL("http://www.google.de/index.html");
                   bin = url.openStream();
                   while((character = bin.read()) >0)
                        System.out.print((char)character);
                        System.out.println();
                   } catch(MalformedURLException e) {
                        System.out.println(e);
                   } catch(IOException e) {
                        System.out.println(e);
    }see yua
    richard

  • GetContent method for custom provider

    Can someone tell me the major resposibilities of the getContent method of a Custom Content provider? The only javadoc comments for this method is "This method has no effect.". That helps enormously! Thanks.

    getContent should return a stringbuffer that contains the content for your channel (usually html).
    JP

  • How to configure the navigation_target URL in method NAVIGATE_ABSOLUTE?

    Fellow develpers,
    In my WDA application, I implemented the method IF_WD_PORTAL_INTEGRATION~NAVIGATE_ABSOLUTE to render a portal iView.  The portal content directory (pcd) of the iView is 'portal_content/iView1'.  The program code is as follows:
    data lo_portal_manager type ref to if_wd_portal_integration.
    call method lo_portal_manager->navigate_absolute
      exporting
        navigation_target   = 'pcd:portal_content/iView1'.
    In execution, the WDA application launches the URL
    https://<host>/irj/portal?NavigationTarget=pcd:portal_content/iView1
    Where can we configure so the WDA application launches the folloinwg URL instead?  https://<host>/irj/servlet/prt/portal/prtroot/nexeninc.portal_content?NavigationTarget=pcd:portal_content/iView1 
    Thanks
    Bac Quan

    Hello,
    should your nav target not be of the format:
    ROLES://portal_content/role/page_in_role/iView_in_role ????
    NB ROLES://
    >Keep in mind that the iView/page used as the navigation target must be assigned to the user role. If it is not, navigation cannot be triggered.
    Check out the help.

  • ASP url, post method

    Hi all,
    I' m working on a web crawler to crawl information about company. I need to get information from a web company register http://www.ur.sk.
    Url with all needed information looks like this one: http://www.ur.sk/index.asp?lang=&stranka=3&ID=0&ico=35700921 where Ico is known ID of slovak company but ID is unknown.
    All I need is to search the company using this form http://www.ur.sk/index.asp?stranka=1. For example you can try to write this ICO number in the form 36513873 and click 'Hladat'. From the search results it's able to get wanted url after clicking the button 'Vypis'. Form uses post method but when I try to figure out a url with query strings it's not working.
    Can anyone help me to go through that form and get the wanted url with correct ID in it..?
    Thanks

    An idea. Add attributes charset and throwOnError to the
    cfhttp tag. remove the port attribute. Then wrap everything around
    try/catch. Hopefully, that should tell us a bit more if it were to
    fail again.
    <cftry>
    <cfhttp URL="https://<url
    address>:444/2serverAuth.asp"
    method="POST" charset="UTF-8" throwonerror="yes"
    resolveurl="false" timeout="60">
    <cfhttpparam type="Header" name="Accept-Encoding"
    value="deflate;q=0">
    <cfhttpparam type="Header" name="TE"
    value="deflate;q=0">
    <CFHTTPPARAM type="HEADER" name="User-Agent"
    value="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)">
    <cfcatch type="any">
    <cfdump var="#cfcatch#">
    </cfcatch>

  • Connect Java with SSRS URL Access method

    I am trying to connect SSRS with Java to display the reports in a browser.
    My application is java 1.6 Swing application and use Applet.I read the article
    http://www.javaworld.com/javaworld/jw-01-2005/jw-0110-sqlrs.html?page=4
    But I am not able to understand why do we need the servlets the authors has mentioned.
    I am able to connect and get back the report in pdf format without these servlets .Also what sort of access will be required for this.
    Will all external users need access to the report server.
    Some one please help
    Any other suggestion for connection SSRS with JAVA .I have tried webservice method and it dint work either now I am planning for url access
    but need help with this
    Thanks

    Can anyone please help.I can provide any more info if needed.I tried the URL method but I get no response in my stream.
    I can post the code i am using in the servlet.

  • Need help adding filter criteria for reports with the GO URL + Post method.

    In attempts to hide some of the information from the URL, we've decided to go pull the parameters out of the url used in the GO Url method. We've managed to get it to retrieve the report and display it without showing the user name and password how we cannot seem to pass in any search criterias.
    The following is what i have:
    Can anyone help me with this issue? or provide any suggestions?
    Thanks!
    form id="form1" runat="server" action="http://452.342.424.421/analytics/saw.dll?Go" method="post">
    <input runat="server" id="Cmd" type="hidden" name="Cmd" value="Answers"/>
    <input runat="server" id="nqUser" type="hidden" name="nqUser" value="admin"/>
    <input runat="server" id="nqPassword" type="hidden" name="nqPassword" value="admin"/>
    <input runat="server" id="Path" type="hidden" name="Path" value="/users/abid.farooq/Countries" />
    <input type="hidden" name="Options" value="fr" />
    <input type="hidden" name="Action" value="Navigate" />
    <input type="hidden" name="P0" value="1" />
    <input type="hidden" name="P1" value="eq" />
    <input type="hidden" name="P2" value="%22Location%22.%22Country%20ID%22" />
    <input type="hidden" name="P3" value="CHN" />

    Hi,
    Instead of this,
    <input type="hidden" name="P2" value="%22Location%22.%22Country%20ID%22" />
    can you try this:
    <input type="hidden" name="P2" value='"Location"."Country ID"' />
    Here, instead of enclosing the value in double quotes, enclose in single quotes. Also replace %22 and %20 with double quotes and space.
    Try it and let me know if this helps!
    Thanks

  • URL & POST Method

    I need to open a connection and send text data to a php script at my web site. I know that I can pass the data with URL like ( for example ):
    http://mywebsite/test.php?param1=value1&param2=value2 ....etc
    and when I pass this string to the URL class, that's mean that I use the GET Method.
    I need to use the POST method to be able to send a text data whatever the size. How?
    Thank's

    Pass "http://mywebsite/test.php" to the URL constructor. Open the connection, call setDoOutput(true), and set the content type to "application/x-www-form-urlencoded". Then write "param1=value1�m2=value2 ....etc" to the connection output stream.
    Russ Cole

  • SOAP Receiver adapter target url and method details

    Hi Friends,
    I am working on file to SOAP interface.
    I know using SOAP receiver adapter , we need to have target URL and action.
    Here, how client need to give target url and action as they are not aware of these things..please suggest.
    Also if we are generating inbound service interface,how they have to handle this from their end.
    Thanks
    Kishore

    Get the WSDL file from ur Third party client and u can use the WSDL file as an External definition in PI and WSDL file also has WSDL URL which u can use in SOAP receiver adapter.
    For INbound SOAP case-
    Generate the WSDL file in XI and give that WSDL file to ur third party client which will send the data using the WSDL URL mentioned in the file.
    refer below blog for understanding in detail:-
    How to use SOAP adapter:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40611dd6-e66e-2910-f383-e80fb44f9cd4
    chirag

  • Redirecting url through method call

    I am using Jdev Build JDEVADF_11.1.1.6.0_GENERIC_111205.1733.6192.1 for my development.
    I have to redirect to different url based upon some conditions in my logic.
    but when I am redirecting I am getting Response already commited error..
    I am using below code to redirect..
    public void redirectToLandingPage() {
    FacesContext fctx = FacesContext.getCurrentInstance();
    // ExternalContext ectx = fctx.getExternalContext();
    String currentViewId =
    FacesContext.getCurrentInstance().getViewRoot().getViewId();
    String viewId = "/oracle/webcenter/portalapp/pages/LandingPage.jspx";
    ExternalContext ectx = FacesContext.getCurrentInstance().getExternalContext();
    HttpServletResponse response = (HttpServletResponse)ectx.getResponse();
    String url = ectx.getRequestContextPath()+"/"+viewId;
    try {
    response.sendRedirect(url);
    fctx.responseComplete();
    } catch (Exception ex) {
    ex.printStackTrace();
    I also tried
    public void redirectToLandingPage() {
    FacesContext fctx = FacesContext.getCurrentInstance();
    ExternalContext ectx = fctx.getExternalContext();
    String currentViewId =
    FacesContext.getCurrentInstance().getViewRoot().getViewId();
    String viewId = "/oracle/webcenter/portalapp/pages/LandingPage.jspx";
    ControllerContext controllerCtx = null;
    controllerCtx = ControllerContext.getInstance();
    String activityURL = controllerCtx.getGlobalViewActivityURL(viewId);
    try {
    ectx.redirect(activityURL);
    } catch (IOException e) {
    e.printStackTrace();
    but getting same error.
    any help would be appricated.
    Regards,
    Kiran.

    This is what I use after logout, in order to sent user to login page :
        FacesContext context = FacesContext.getCurrentInstance();
        HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
        HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getResponse();  
        String url = request.getRequestURL().toString();
        StringBuffer sb = new StringBuffer(url);
        int indexOfRequestURI = url.indexOf(request.getRequestURI());
        sb = sb.replace(indexOfRequestURI, url.length(), request.getContextPath() + request.getServletPath() + "/login.jspx");
        String redirectUrl = response.encodeRedirectURL(sb.toString());
        response.sendRedirect(redirectUrl);
        context.responseComplete();

  • URL getContent failing to determine content type

    Within my application I am trying to load a file using the URL class. The file is deployed to the web directory /reports/report.txt. If I use the following code it returns to me the message "no content-type" and fails to load the content of the file. I am not sure how to get this to determine the content type or what I need to modify to get this to load the file. Any pointers would be appreciated.
    Stirng templateUrl = "/myApp/reports/reports.txt";
    URL url = new URL("http", "localhost", 7001, templateUrl);
    URLConnection conn = url.openConnection();
    logger.debug("content type: " + conn.getContentType());

    mperemsky5 wrote:
    Within my application I am trying to load a file using the URL class. The file is deployed to the web directory /reports/report.txt. If I use the following code it returns to me the message "no content-type" and fails to load the content of the file. I am not sure how to get this to determine the content type or what I need to modify to get this to load the file. Any pointers would be appreciated.
    Stirng templateUrl = "/myApp/reports/reports.txt";
    URL url = new URL("http", "localhost", 7001, templateUrl);
    URLConnection conn = url.openConnection();
    logger.debug("content type: " + conn.getContentType());So my first question is:
    Does this file exist localhost/myApp/reports/report.txt ?
    If it does type in localhost/myApp/reports/report.txt and it should show in your browser.
    If not, then yes, you don't have any content there.

Maybe you are looking for

  • Mac Ports not working

    Hi, I have been trying to install frozen bubble on my iMac, but I haven't been able to get it to work. I installed xcode, and then macports. After that, I typed this in the terminal: sudo port install frozenbubble2 However, the terminal just hangs. I

  • To pre-sign or not to pre-sign...

    that is the question. Granted, the terms and conditions are very straight forward in stating a complete write-off of ALL responsibility (see below)...has anyone done this before and what is your recommendation/experience? Seeing as I will likely be a

  • Why isn't photoshop working in my membership? It keeps telling me that i have to buy it,

    Yesterday i has decided to take a membership on adobe cc, with the following programs, lightroom and ps. The photoshop trial is already past, that's what my cc account says, so i have to buy it. The lighroom version is now on a trial. How can i get m

  • Preverify error when netbean 4.0 build classes that import device lib

    ERROR: native methods should not appear Error preverifying class com.sprintpcs.media.Clip

  • Annoying bug when exporting

    I get a problem when i try to export using quick time conversion and then suddenly switch to another app like mail for example. When i go back to final cut express i cant come any further. the dialog box shows cancel or save, neither of which is effe