Open a URL from Servlet

Hi,
          I'm running a servlet and wants to open a URL for a file, how do I do that ?
          (To get the same effect as if I open the file from a browser)
          thanks in advance..
          ..Per
          

If you mean to read the contents of a URL, then see URL.getConnection. If
          you mean to download a file to a browser, then search this newsgroup for
          "download".
          Cameron Purdy
          Tangosol, Inc.
          http://www.tangosol.com
          +1.617.623.5782
          WebLogic Consulting Available
          "Per Lovdinger" <[email protected]> wrote in message
          news:3a9a7650$[email protected]..
          > Hi,
          >
          > I'm running a servlet and wants to open a URL for a file, how do I do that
          >
          > (To get the same effect as if I open the file from a browser)
          >
          > thanks in advance..
          > ..Per
          >
          >
          

Similar Messages

  • Want to open a URL from java application?

    I want to open a URL (say http://yahoo.com) from my java application without using servlets. PLzzz help asap

    Include these packages:
    import java.net.*;
    import java.io.*;
    Proxy Setting If any:
    //getProxy your proxy address default "No Proxy".
    if (!getProxy.equals("No Proxy"))
    System.getProperties().put("proxySet","true");
    System.getProperties().put("proxyHost",getProxy);
    System.getProperties().put("proxyPort","80");
    Main code:
    URL url = new URL("http://mail.yahoo.com");
    URLConnection connection1 = url.openConnection();
    String filetext=postURL(connection1);
    Function postURL:
    public String postURL(URLConnection connection)
    try
    BufferedReader httpResponse = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    String line = new String();
    StringBuffer buffer = new StringBuffer();
    while((line=httpResponse.readLine())!=null)
    buffer.append(line);
    httpResponse.close();
    return buffer.toString();
    catch(Exception e)
    System.out.println("Error:"+e);
    return "Error4" ;

  • If I open another URL from my homepage, the "go back one page" button is grayed out so I can't get back to my home page.

    This problem only started recently.
    Opening another web page (URL) from my homepage always opens in the same tab and the "go back one page" button is gray and does not work. If I open a series of web pages in the same tab the green "back" button is green. Clicking on the "recent pages" down arrow will allow me to go back, but only to the page after the home page.
    In other words, after browsing, I can get back to the opening page (my home page) only by clicking on the house icon but not by using the "recent pages" function.
    Is there an option that changed after the last update?

    Do you see any tab history if you right click the Back or Forward button?
    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]

  • Opening an URL from a JAVA application

    hi,
    iam new to Java.
    Currently iam designing a simle GUI which takes input(URL) from user in a test field and has a button.Upon clicking button i want to open the webPage specified by that URL in a default webBrowser.
    How can i do that(opening webPage)?
    advanced thanks for your help.
    vd.rach

    getting an error on that line as follows: "unreported
    exception; must be caught or declared to be thrown".exec() throws IOException so catch it.
    try {
    Runtime.getRuntime.exec(...);
    catch(IOException e) {
    System.err("Cannot launch the browser: " + e.getMessage());
    }On the side note: I found javaworld's [url http://www.javaworld.com/javatips/jw-javatip66_p.html]solution most useful in serving this purpose in a project, even though its a little bit platform specific.

  • Issue in opening an URL from UI

    Hi Experts,
    When clicking  button in an assignment block of campaign screen, it should open an URL (SRM screen) in new window.
    I have written the following code in htm page inside script tag.
    window.open("lv_url").focus();
    lv_url is obtained from the eventhandler onclick.
    First time, when I click on the button, the URL is opened in the new window successfully. If I close that window (SRM screen),
    and click on the button again, it is executing the code window.open but not opening a new window. Please help.
    Thanks,
    Ramya

    Hi Ramya,
    The problem is with the window handler. That is the window handler doesnt terminate even when you manually close the new window and so when attempting to open a same url it doesnt show up.
    One solution is to generate a guid and pass it with the url so that the url will differ (since the guid differes the url will not be the same). Check the below sample code,
    <%
    CALL FUNCTION 'GUID_CREATE'
       IMPORTING
         EV_GUID_32       = lv_guid.
      CONCATENATE 'guid=' lv_guid INTO lv_query.
      CALL METHOD cl_crm_web_utility=>create_url
        EXPORTING
          iv_path                     = lc_path
          iv_query                   = lv_query
          iv_absolute               = lc_flag
          iv_in_same_session = lc_flag
          iv_server_object      = server
          iv_no_cookie            = 'X'
        RECEIVING
          ev_url                       = lv_url.
    %> 
    <scirpt language="javascirpt">
         window.open(' <%= lv_url %> ');
         window.close();
    </script>
    Regards,
    Arun

  • Opening a file from Servlet

    Hi,
    I`m trying to open a file from Tomcat Servlet init method but it fails with java.io.FileNotFoundException: test.properties (The system cannot find the file specified).
    The code is:
                                  File f = new File("test.properties");
                                  DataInputStream is = new DataInputStream((new FileInputStream(f)));
                                  System.out.println(is.readLine());
                                  is.close();
    test.properties is in /WEB-INF/classes directory.
    What is the classpath for a web app and is it possible to adjust it?
    Thanks,
    vs

    What is the error saying???
    Are you sure the file location is right?
    MeTitus

  • Not able to dispatch to an URL from servlet

    Hi ,
    I am trying to call a URL from a servlet, which is running in an oc4j instance of Oracle AS 10.1.2.0.2
    My servlet (session_servlet) basically reads the session id, whenever it is accessed. It then inserts this session id into a table in an oracle database. Then, I want to access my Oracle Forms application from session_servlet, by dispatching to the URL, say
    http://<my_host>/forms/frmservlet?config=test&session_id=<the_session_id_read_by_session_servlet>
    session_servlet and frmservlet are running on the same Oracle AS, but on different http servers, session_servlet on port 7777 and frmservlet on the default 80.
    <code snippet of my session_servlet, where I am dispatching to the URL>
    getServletContext().getRequestDispatcher("http://<my_host>/forms/frmservlet?config=test&session_id="+session.getId()).forward(request,response);
    But am getting the following error
    500 Internal Server Error
    java.lang.NullPointerException
    at session_tracker.doGet(session_tracker.java:54)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:826)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:332)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.AJPRequestHandler.run(AJPRequestHandler.java:224)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.AJPRequestHandler.run(AJPRequestHandler.java:133)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
    at java.lang.Thread.run(Thread.java:534)
    Can someone please help me on this.
    Thanks,
    Suresh

    getServletContext().getRequestDispatcher("http://<my_host>/forms/frmservlet?config=test&session_id="+session.getId()).forward(request,response)
    From the Javadocs for ServletContext.getRequestDispather():
    http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContext.html#getRequestDispatcher(java.lang.String)
    The pathname must begin with a "/" and is interpreted as relative to the current context root. Use getContext to obtain a RequestDispatcher for resources in foreign contexts. This method returns null if the ServletContext cannot return a RequestDispatcher.
    -steve-

  • Opening a URL from a Java Program

    Hi all,
    Can I open Internet Explorer and invoke a URL from a Java Program. If it can be done, could someone please give a code for that.
    Thanks in advance.

    Did you try it like "start \"http://java.sun.com\""
    or maybe
    "start 'http://java.sun.com'"I've no idea whether that will work, but it would be the first thing I'd try.

  • How can I open a URL from a Custom Button in a second help window?

    I have a custom button, which currently opens a URL in a web
    browser, using a redirect page. How can I change this so that it
    opens in a second help window instead? If I understand some of the
    posts I've read, it is possible by linking the button to a related
    topics function but I've no idea how this is done.
    As usual, your help is most appreciated. Thanks a lot.

    Hi, ecoulyn,
    You need to make a topic file like the one below the target
    of the Jump button.
    The onLoad function on the Body start-tag causes the Related
    Topics command to fire when the topic file is loaded in the topic
    pane. When specifying the file name of the topic to display in the
    secondary window, you must always prepend it with the name of your
    .chm file, followed by "::/". Otherwise, an error message appears
    when the Jump button is clicked.
    Pete

  • Open a URL from InDesign (JS OSX CS3)

    Hi -- I have some limited experience javascripting In InDesign. Most of what I have done focuses on text and documents, so I need to ask a question that is outside my current experience.
    I am trying to write an Indesign script that when deployed by a user opens a URL in a Web browser. It would be the same url every time -- not dependent on any hyperlinks that may or may not be in a document.
    Is there anyway for me to use a Hyperlink.showDestination()function to accomplish this using this static URL within the script? If so, I am unsure how to proceed.
    Any thoughts would be greatly appreciated.
    thanks

    Check out this post.
    Kasyan

  • How to open an URL from Forms in blocking mode?

    Can anyone tell me if it is possible to open a website from within forms in blocking mode? The reason why I have to use blocking mode is that the user has to take some action in the website and has to end that session explicitly with a button on the website. After that, a file is written on the server that is needed for further action. Without that file the process can't go on.
    I use Forms (32-bits) versie 10.1.2.0.2.

    Thanks for your answer.
    Your suggestion is only possible with a timer-trigger (correct me if I'm wrong). And that's the point.... The time the user can act in the website is unlimited. So, how to set up a timer-trigger? Another work around is to make a process that works at some time and searches for the files on the server. But that's not what we want to do.
    Does anyone have another idea?

  • Opening a URL from an application

    Hi everyone, am not quiet skilled with java but i would really appreciate your help with this, as i couldn't find a solution which made me doubt my whole basic knowledge of java. Now am doing this for my school project, it's a speech recognition application that will convert speech to text, there are 2 buttons in my interface, one "start" where you start speaking , the other one "stop" which would allow the engine to start processing the speech and converts it to text, it will then open a web page which in my case is a search engine(say google or yahoo) and searches for the matching documents of what has been spoken.
    my problem is that i need to open that certain URL ( predefined) from a running application and not an applet, it hasn't worked for me, This is the only problem. is it possible ? please i need your help with this , i'd really appreciate it if someone would help ... thanks a lot for your time.

    hii guys am really sorry for the confusion ,the problem was actually with the java security poilcy not with the code as i thought.. i thought my code was wrong but it turned out to be correct.. here it is for anyone who's interested... but thanks anyway for everything... tc
    Runtime rt = Runtime.getRuntime();
    rt.exec("C:/Program Files/Internet Explorer/iexplore.exe http://www.google.com/search?hl=en&q=hi+my+name+is+omaya");

  • Middle mouse button in FF 4.0, Linux, does not open new url from clipboard

    In new version FF 4.0 on Linux, middle mouse button doesn't open url (which is copy from clipboard in Linux style) without http:// prefix. It open url in format "http://www.mozilla.com" but doesn't open "www.mozilla.com". It works properly in previous versions FF.

    And, wouldn't you know it, an hour after posting I found the simple solution...
    Someone suggested that the Logitech RX300 mouse had a problem with mapping the middle (wheel) mouse button - try another one.
    I tried 4 various mice - they all worked. The Logitech RX30x mice needs some adjustments.

  • Opening a URL from a button within a Web Template

    Hi All,
    I have a requirement to provide report specific help from within a standard web template. Assuming that I had a list of help URLs for each report and an intermediary way to redirect to those URL based upon a unique id such as the reports technical name, is it possible to create a generic button from within a web template that would dynamically create a URL based on the reports technical name? I.e., http://www.example.com/page.html?ZGTRPTNME
    To date I have only used the Action "Command via Command Wizard" from within the parameters of the button Web Item. However, I did notice that a Script Function was provided. Has any used this functionality and is it possible to create a URL with the technical name of the report?

    Rekesh,
    I had a look at the document you linked however what I need to find out is how I can place the technical name (dynamically) within the web template URL (i.e., this needs to work for multiple projects over many reports that all use the same global web template).
    It's actually very easy opening a new window via javascript however finding the varible for the report technical name remains unclear. At present I am looking at command URL's. The only other option is that I use a java script substring command to pull the report technical name from the URL (although this not as clean as using command URL's).
    EDIT: Found this document: http://help.sap.com/saphelp_nw70ehp1/helpdata/en/43/ef9a6c13f2025be10000000a1553f7/content.htm
    Appears that the command: sapbi_page.GetMainTemplateName(); will give me the technical name of the webtemplate although I'm finding it hard to find the command for getting the technical name of the current report.
    Edited by: Paul Thomson on Feb 18, 2010 4:00 PM

  • Calling simple URL from servlet.

    Hello,
    i need your help. I must call a simple URL (for example) "www.sun.com" from my servlet. How can i do this ? Sorry for stupid question, but i don't know how...
    Dmitri.

    I didn't know, Lgmqy2000, that i can delete "Duke"....... i tried to cancel it, but without results...
    Dmitri

Maybe you are looking for

  • Trying to link 2 e4200 routers together on same network via a switch

    I have had my internet working fine for a long time with e4200 routers joined together via a 5port switch in the middle of the house. I have not ever been able to see computers however hooked from one router to those hooked to the other router. I hav

  • Oracle text indexed view is possible

    Oracle text indexed view is possible???

  • How to export a finished video to mac user.

    The video is saved as an MP4 format on my Lenovo computer. My daughters uses a Mac. She can't view it. Help.... Billy

  • HH5 Speed Drop - Infinity 2

    Hello Guys, I just installed the new HH5 I got for free from BT.  I was using the HH4. I am only getting 47MB download speeds compared to 67MB from the HH4...?  Upload speeds seem to be the same. Ping also seems to be a little higher on the HH5 to 32

  • Asset Class

    T.Code for assignmnet of Depriciation key to asset class.As while creating asset depriciation key is not picking based on asset class. Regards Kapex.