Browser launch from Servlet

Hi,
In my servlet code, am forming an URL and then launching it in system default browser using below code -
public static void openURL(String url) {
String osName = System.getProperty("os.name");
try {
if (osName.startsWith("Mac OS")) {
Class fileMgr = Class.forName("com.apple.eio.FileManager");
Method openURL = fileMgr.getDeclaredMethod("openURL",
new Class[] {String.class});
openURL.invoke(null, new Object[] url);
else if (osName.startsWith("Windows"))
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
else { //assume Unix or Linux
String[] browsers = {
"firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" };
String browser = null;
for (int count = 0; count < browsers.length && browser == null; count++)
if (Runtime.getRuntime().exec(
new String[] {"which", browsers[count]}).waitFor() == 0)
browser = browsers[count];
if (browser == null)
throw new Exception("Could not find web browser");
else
Runtime.getRuntime().exec(new String[] {browser, url});
} catch (Exception e) {
Say, servlet is on server A. When i invoke it locally (server A), it launches URL in browser but when i invoke servlet remotely (server B), it still launches url in browser on server A and not on B.
Any idea how can i redirect the response to the remote browser ??
Thanks,
Deepak

Deepak2001 wrote:
What i am interested in knowing is how to redirect the response back to client from where the request originally generated.This question is too vague. Please elaborate. All what I can think about is that you just need HttpServletResponse#sendRedirect().

Similar Messages

  • Closing a browser window from servlet

    Hi
    I generate a pdf document using itext and open it in a web browser which has a button save and close, on the click of this button, a servlet is been called. Now my question is, after the execution of the servlet, I need to close the browser where the pdf was shown. How do I achieve this.
    Any help is greatly appreciated.
    Thanks

    On the server response, write something like
    <html>
    <head></head>
    <body>
    <script>window.close();</script>
    </body>
    </html>There's no way that I know of to close the browser inside the servlet as the servlet is not executed on the browser, but in the server ;-) So you may have to play with Javascript to do that.

  • Web browser launched from B1

    hey All,
    I have done a nice bit of research on the topic of opening a web browser via the UI API in the B1 client. I cannot seem to find any examples or working code to do this. Yes there are samples of active x controls but none of them ever seem to work.
    Does anyone have some sample code or logic that I could use to launch an windows form with an active x control web browser from the B1 client?
    Any help is appreciated
    Curtis

    Hi Curtis,
    Does the following article help you at all?
    http://support.microsoft.com/default.aspx?scid=kb;en-us;Q305703
    Strictly speaking, it doesn't open a webpage in a SBO form or a windows form, it opens your default browser.
    Kind Regards,
    Owen

  • Browser launch from JSP

    {color:#0000ff}Hi,
    {color}
    In my jsp code, am forming an URL and then launching it in system default browser using below code -
    public static void openURL(String url) {
    String osName = System.+getProperty+("os.name");
    try {
    if (osName.startsWith("Mac OS")) {
    Class fileMgr = Class.+forName+("com.apple.eio.FileManager");
    Method openURL = fileMgr.getDeclaredMethod("openURL",
    new Class[] {String.*class*});
    openURL.invoke(*null*, new Object[] url);
    else if (osName.startsWith("Windows"))
    Runtime.+getRuntime+().exec("rundll32 url.dll,FileProtocolHandler " + url);
    else { //assume Unix or Linux
    String[] browsers = {
    "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" };
    String browser = null;
    for (*int* count = 0; count < browsers.length && browser == null; count++)
    if (Runtime.+getRuntime+().exec(
    new String[] {"which", browsers[count]}).waitFor() == 0)
    browser = browsers[count];
    if (browser == null)
    throw new Exception("Could not find web browser");
    else
    Runtime.+getRuntime+().exec(*new* String[] {browser, url});
    catch (Exception e) {
    {color:#0000ff}Say, JSP is on server A. When i invoke it locally (server A), it launches URL in browser but when i invoke jsp remotely (server B), it still launches url in browser on server A and not on B.
    Any idea how can i redirect the response to the remote browser ??
    Thanks,
    Deepak {color}

    Crossposted and already answered: [http://forums.sun.com/thread.jspa?threadID=5320443].
    Don't crosspost. It is rude in terms of netiquette and wastes other's time.

  • Display PDF document from Servlets to browser - how 2 change the title

    Hi, need help of changing the html title when Display PDF document from Servlets to browser. By default the browser's title shows the obsolute URL where the rdf comes from (i.e. http://www.google.com/sample.pdf), because servlet responds a binary data (PDF), there seems to be no other way to change the browser's title to fit my own choice.
    Appreciate your quick help,

    You can try and check with
    .setTitle("Welcome");

  • Control browser properties from a java application while launching a browse

    How to control the properties of a browser when it is launched from a java application?
    I am using the command " Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+url); " to launch the browser. The syntax of "exec" command is "public Process exec(String command,String[] envp) throws IOException". I would like to know whether we can give the arguments in this command to control the browser properties.
    If you know any other option by which we can open a URL in a controlled browser, please share it.
    Thanks in advance :).
    Surekha_Venugopal

    Hi All,
    I have found a solution to control browser parameters from Java applications.
    1. Create an intermediate HTML file at runtime which contains Javascript to launch a browser. Pass the parameters like the URL and browser control parameters to the Javascript of this HTML file.
    2. Open this HTML file and invoke the javascript while loading the file. Javascript will launch the required URL in a controlled browser.
    3. Close the intermediate HTML file.
    Limitation:
    1. There will be a flickering of windows.
    2. Applets will have permission issues with the above solution. For applets a better solution is JSobject. No need of an intermediate file here.
    Hope this will be useful for someone. :-)
    Cheers,
    Surekha_Venugopal

  • Close a browser  window from a servlet

    I am newbie and am trying to close the browser window from my servlet without prompting as my servlet is designed to run as a batch app.
    The servlet is invoked by a scheduling agent and performs the batch function , but leaves the browser window open . I
    need help
    Thanks
    VK

    I am newbie and am trying to close the browser
    window from my servlet without prompting as my
    servlet is designed to run as a batch app.
    The servlet is invoked by a scheduling agent and
    performs the batch function , but leaves the browser
    window open .I don't see the problem with that. The users can easily close the browser if they want to. It's possible that some Javascript could be used to close the browser window but it's user-unfriendly and shouldn't normally be done.

  • Problem in Passing JTree object from Servlet pgm to browser

    Dear all:
    Can anybody help to resolve the problem - pass the JTree obejct from servlet (Tomcat) to IE 6.0. The JTree oject alway shows invalid charcter in IE. Following is my coding.
    import java.io.*;
    import java.awt.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.swing.*;
    import java.net.URL;
    import java.sql.*;
    import java.lang.*;
    import java.util.*;
    import javax.swing.tree.*;
    //* Testing1 give it null
    public class SimpleServer extends HttpServlet
    DefaultMutableTreeNode top;
    DefaultMutableTreeNode EX01;
    DefaultMutableTreeNode EX02;
    DefaultMutableTreeNode QB01;
    DefaultMutableTreeNode QB02;
    DefaultMutableTreeNode N2BS;
    DefaultMutableTreeNode N2TS;
    //StringTokenizer st2, st1;
    String query;
    Connection con ;
    Statement statm;
    ResultSet res, backupRes;
    //RowSet res, backupRes;
    TreeSet treeset ;
    String [] tempArray;
    //ServletContext sc ;
    ObjectOutputStream out ;
    DefaultMutableTreeNode temp_node;
         public void doGet(HttpServletRequest req, HttpServletResponse resp)
         throws ServletException, IOException
    resp.setContentType("text/html");
    // resp.setContentType("application/octet-stream");
    System.out.println("create main node") ;
              out = new ObjectOutputStream(resp.getOutputStream());
              out.writeObject(this.set_NodeMain()); //no DB access,
         public void doPost(HttpServletRequest req, HttpServletResponse resp)
         throws ServletException, IOException
         try
         System.out.println("doPost " );
         doGet(req,resp);
              finally
         public DefaultMutableTreeNode set_NodeMain()
    top = new DefaultMutableTreeNode("Tandem");
    EX01 = new DefaultMutableTreeNode("EX01");
    EX02 = new DefaultMutableTreeNode("EX02");
    QB01 = new DefaultMutableTreeNode("QB01");
    QB02 = new DefaultMutableTreeNode("QB02");
    N2BS = new DefaultMutableTreeNode("N2BS");
    N2TS = new DefaultMutableTreeNode("N2TS");
    top.add(EX01);
    top.add(EX02);
    top.add(QB01);
    top.add(QB02);
    top.add(N2BS);
    top.add(N2TS);
    return top;
    }

    JMO - I hate seeing things like this in code:
    Just use whitespace to separate the methods.
    You can't just send a JTree to a browser. A browser has no idea how to render a Java object.
    Put that JTree inside an applet and make it part of a JSP. That'll work.
    MOD

  • Browser size when launched from Forms Builder

    Hi, Does anyone know how to set the size of the IE browser when launched from Forms Builder? I have set the width and height setting to 100% so that the applet takes up all the browser space, however the browser is still not as large as I'd like.
    When I start IE on its own, it opens in the desired size, it's only when running it from Forms Builder that it's too small. I've searched on the net, but nothing seems to work, there must be a setting specific to Forms?
    Thanks
    Sam

    If you are using SeparateFrame = True, then you might try using these in your When-New-Form-Instance trigger:
    set_window_property(forms_mdi_window, window_state, maximize);
    set_window_property('Your_Main_Window', window_state, maximize);
    If you are not using SeparateFrame = True, then you may have to use JavaScript in the page where your applet is located. Javascript can also go in your formsweb.cfg file. See:
    HTMLbeforeForm=<script>....</script>
    or
    HTMLafterForm=<script>....</script>

  • Multiple projects, yet one flash file launched from browser

    Hello everyone, I glad to be a part of this wonderful community.  I have a really sticky Captivate 4 problem, and I wanted to get my feelers out there now before I really need to get this done before the end of the week.  This question has to do with publishing.  I have 7 project files, and I created a "menu" slide at the end of each of them that look exactly the same.  In this particular slide, there are 7 'click boxes' spread throughout the page that launch all the other projects.  If you are wondering why I did this, it's because I'm trying to cut back on load time when a user click on any individual project.  Now, my programmer can only launch one .swf file from our webpage to get the first project started.  So, does this mean Captivate will dynamically handle launching all of the other projects(assuming multiple flash files are created) when they are launched from these "menu" slides?  I'm a bit confused.  I'm likely confusing some of you as well.  It is hard to put the problem into writing.  Please help!

    Okay, so lets look at the problem, shall we?
    You created seven projects. But you later asked:
    So, does this mean Captivate will dynamically handle launching all of the other projects (assuming multiple flash files are created) when they are launched from these "menu" slides?
    First off, with seven different projects, you end up with seven different outputs. Assuming you are using Captivate in the basic form, you will end up with seven different SWF files and seven different HTM files that need to be factored into things. You may have more files than that, depending on your options used.
    When you create the links using the Click Boxes, hopefully you used the option: Open other project. This means that when the user clicks, the other SWF/HTM or EXE (depending on output) will be launched.
    I'm sure you will have other questions. So just post back either in threads of their own or by replying to this thread.
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • How can I display the HTML page from servlet which is called by an applet

    How can I display the HTML page from servlet which is called by an
    applet using the doPost method. If I print the response i can able to see the html document. How I can display it in the browser.
    I am calling my struts action class from the applet. I want to show the response in the same browser.
    Code samples will be appreciated.

    hi
    I got one way for this .
    call a javascript in showDocument() to submit the form

  • How do I set the Launch window size (from launch from an LMS) in Captivate 5.5?

    When my project launches from the LMS, the lauch window is smaller that the actual project size and requires the user to resize the window to see the whole project. My LMS administrator tells me that the launch window size is not controlled by the LMS so I am trying to figure out how I can set this to match the project dimensions.

    The size of the browser window CAN be controlled by the LMS, but some LMSs are hopeless in this area and don't provide the settings to do so.
    Moodle for example allows you to specify that the course content will open in a new window each time an item in the LMS TOC is clicked and what the height and width of that window will be. However, all versions of SumTotal before the latest one did not give you this option (and that despite the exhorbitant price difference between these two products.)
    So your LMS admin might be correct in that HIS particular LMS cannot control the size of the launch window, but that's not because no LMS can do this.

  • How do I fix my Out Of Browser launcher?

    I've been working on a Desktop Client project and experimenting with the options of Web display and Desktop display.
    Somehow I have broken my project such that if I try to use the Desktop display, the project fails to run and gives the Out of Browser launcher has stopped working message. The browser option still works fine.
    I don't know what went wrong with my project or whether my project broke something in the registry, but I'm pretty certain that the problem was caused by my project because....prior to trying to run the project, I checked everything in to source control.
    Then my project failed to run as the Desktop display. Then I went to a co-worker who downloaded the project from source control and she got the same Out of Browser launcher has stopped working message.
    Also, I then created a brand new simple Lightswitch project and put one screen in it. It won't run as a Desktop application either.
    I uninstalled Silverlight and reinstalled it. 
    Still, my Out of Browser launcher is not working.
    Does anyone know how to get it working again?

    Hi,
    Welcome to LightSwitch forum.
    We can configure Silverlight-based applications so that users can install them from their host Web pages and run them outside the browser. 
    According to your description above,  I'd like to suggest you to check
    Out-of-Browser Support in your application, perhaps it will help you fix it.
    Best regards,
    Angie
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Safari 2.0.3 won't launch from Mail

    Since the new security update yesterday for OS X4.5, my Safari browser 2.0.3 won't launch from the Mail e-mail program.
    What do I do now? It was working perfectly before the update.
    Kathy : (

    I've had the same problem using numerous apps and on different Macs since updating to 10.4.5. Today, using the "check for updates" in Quicken 2006, something corrupted Safari completely and it won't launch at all - double click merely shows the icon in the Dock for a second before it quits. I did all the usual stuff: deleted the cache, cookies, etc. Finally trashed the app but now I can't figure out how to reinstall it alone...
    G5 1.8x2, G4 450x2, PB 12-inch, iBook 300, iMac SE   Mac OS X (10.4.5)  

  • Browse image from database

    hi evey body
    i wish some one help me for solve this problem .
    when i use jdeveloper 11g to browse image from database using servlet (*without using Dynamic JDBC Credentials*) i can browse the image,
    but when i use jdeveloper 11g to browse image from database using servlet with the solution by Steve Muench, Dynamic JDBC Credentials i always get this error :
    java.Null.pointerException
    Caused By: java.sql.SQLException: ORA-01005: null password given; logon denied
    at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
    at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:406)
    Truncated. see log file for complete stacktrace .
    my question why i get this error? is servlet open new session ??
    thanks in advance
    maher

    hi every body
    sorry for my repeated request , i wish some body help me to solve my problem or ask me some thing about my problem .
    this the last request for this question and i will not upset you again .
    thanks in advance
    maher

Maybe you are looking for

  • All-In-One IdeaCentre C440, high pitch sound

    I have a problem with my Desktop PC All-In-One Lenovo IdeaCentre C440, machine type: 10104, configuration number: 57322047. I bought this computer last week ago and from the beginning is present a high pitch sound. The high pitch sound is more eviden

  • Retail Tab in the PO line item..

    Hello all! I need this help - Now, I have this "Retail tab" showing up at the PO line item level. It is happening to every PO doc type and Pur org combination. It does not show in Sand box... There is no retail activated at all in the 4.7 version. Ap

  • Get Report Name for Report Painter

    Hi Gurus, I need in an ABAP program to find dynamically the name of a report generated via Report Painter and associated to a TCODE. I got the tcode. How i can find it? I find the cluster number in GRRT but i don't know how to convert it in my report

  • Subsinvprocess in the sales order header --- billing tab and in the custom

    Hello All there is a field SubsInvProcess in sales order header - billing- tab and in the customer master - billing tab what was the functionality of this field. I never worked with it kindly help on this one.  Thanks, prasad

  • Problem with webutil file dialog box when trying to save/open

    Approximately 12 months ago we had this same issue and I think we managed to resolve it with a one off patch. Were getting it on another site now so any info will be much appreicated. Basically when using webutil file chooser Client_Get_File_Name to