Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners opening new browser with new JSESSIONID using java
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


suresh anugandula
opening new browser with new JSESSIONID using java
0 Answer(s)      3 years and 5 months ago
Posted in : Java Beginners


I am facing following problem, I am trying to open a new browser using java. First i have opened one IE browser and manually. And i ran my LaunchURL.java file, it is opening new browser but with the same JSESSIONID of which IE browser window i opened manually. Her it is giving same JSESSIONID for both the windows(one is manually opened and another one is opened by my LaunchURL.java). But that is not my requirement. I have to open a new browser window with new JSESSIONID.

Here is my code:

  • LaunchURL.java

    public class LaunchURL {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        String url="http://10.64.174.166:8080/Popup/popup?phone="+9999999999l;
        BareBonesBrowserLaunch.openURL(url);
    }
    
    }
    
    
    BareBonesBrowserLaunch.java
    import javax.swing.JOptionPane;
    import java.util.Arrays;
    
    public class BareBonesBrowserLaunch {
    
    static final String[] browsers = {"google-chrome", "firefox", "opera",
        "epiphany", "konqueror", "conkeror", "midori", "kazehakase", "mozilla","Microsoft Internet Explorer"};
    static final String errMsg = "Error attempting to launch web browser";
    
    >public static void openURL(String url) {
      try {  //attempt to use Desktop library from JDK 1.6+
         Class d = Class.forName("java.awt.Desktop");
         d.getDeclaredMethod("browse", new Class[] {java.net.URI.class}).invoke(
            d.getDeclaredMethod("getDesktop").invoke(null),
            new Object[] {java.net.URI.create(url)});
         //above code mimicks:  java.awt.Desktop.getDesktop().browse()
         }
      catch (Exception ignore) {  //library not available or failed
         String osName = System.getProperty("os.name");
         try {
            if (osName.startsWith("Mac OS")) {
               Class.forName("com.apple.eio.FileManager").getDeclaredMethod(
                  "openURL", new Class[] {String.class}).invoke(null,
                  new Object[] {url});
               }
            else if (osName.startsWith("Windows"))
               Runtime.getRuntime().exec(
                  "rundll32 url.dll,FileProtocolHandler " + url);
            else { //assume Unix or Linux
               String browser = null;
               for (String b : browsers)
                  if (browser == null && Runtime.getRuntime().exec(new String[]
                        {"which", b}).getInputStream().read() != -1)
                     Runtime.getRuntime().exec(new String[] {browser = b, url});
               if (browser == null)
                  throw new Exception(Arrays.toString(browsers));
               }
            }
         catch (Exception e) {
            JOptionPane.showMessageDialog(null, errMsg + "\n" + e.toString());
            }
         }
      }
    
    }
    

Advertisement
View Answers

Related Tutorials/Questions & Answers:
opening new browser with new JSESSIONID using java
opening new browser with new JSESSIONID using java  I am facing following problem, I am trying to open a new browser using java. First i have opened one IE browser and manually. And i ran my LaunchURL.java file, it is opening new
opening new window - Java Beginners
opening new window  Hi All, I have two classes with me , lets say A and B.when I press a button in class A , the class B should open in a new window.i.e., I want to know, how a new window(B) can be opened by clicking a button
Advertisements
Java - Opening a url in new window from an applet
Java - Opening a url in new window from an applet  ... an applet. This program shows that how a url is opened in a new document or browser. When you click the button "google", new browser window will open
JAVA SCRIPT CODE FOR OPENING A WEBSITE IN A NEW WINDOW - Java Beginners
JAVA SCRIPT CODE FOR OPENING A WEBSITE IN A NEW WINDOW   PLS TELL ME? HOW CAN I DEFINE A WINDOW.OPEN FUNCTION WITHIN ANOTHER FUNCTION e.g... DATA, IT MUST OPEN A WEB SITE IN A NEW WINDOW. SPECIFICATION:MAKING ONLY "1
opening internet browser in java program - Swing AWT
opening internet browser in java program  i want a code to open the internet browser in swing program using JFrame.  Hi Omkar, Use...; browsers.length && browser == null; count++) if (Runtime.getRuntime().exec(new
Opening a browser only with body from a java program
Opening a browser only with body from a java program  Hi all, I got following requirement, Opening a browser window only with body and title bar...) if (browser == null && Runtime.getRuntime().exec(new String[]{"which", b
new
new    hi i am jane pls explain the difference between string greeting = good morning string greeting = new string ("good morning
new
new  hi the difference between string sname = good morning string sname =new("good morning
new
new    hi i am jane pls explain the difference between heap memory and stack memory
Java - Opening a url in new window from an applet
Java - Opening a url in new window from an applet  ... will open new browser window and then show you the web page. Opening a new... on the applet, new browser window will open displaying the specified url, in our
How to create new arraylist using Java
How to create new arraylist using Java  hi, I want to develop... someone provides online example how to create new arraylist in java programming. thnaks,   Hi, In java programming language you can create new
new
new   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html
New to Java - New to java tutorial
Technical description of Java Mail API       This section introduces you with the core concepts of Java Mail API. You must understand the Java Mail API before actually delving
Opening a new window in Echo3
Opening a new window in Echo3   ... will create a new Window. To create this example we have created two class files... of an application. Here we have created a new Window by constructing the object
New To JAVA - Java Beginners
New To JAVA  hi iam new to java..,can you please guide me how to learn the java and also tell me how many days it takes to learn java  Hi naresh, All are depend on you. i am sending link, by using this tutorial you
new java technologies 2012
new java technologies 2012  new java technologies 2012
add new package java
add new package java  How to add new package in Java
new java technologies 2011
new java technologies 2011  what are the new java technologies in 2011
New to Java Please help
New to Java Please help  Hi I need help, can some one help me.... Thanks!   If you are new in java, then you need to learn core java concepts.So go through the following link: Core Java Tutorials Here, you will find
NEW IN JAVA - Java Beginners
NEW IN JAVA  Suppose you are asked to design a software tool... static void main(String[] args) throws Exception { Scanner scan = new Scanner(System.in); Random random1 = new Random(); Random random2 = new Random(); int
Very new to Java
Very new to Java   hi I am pretty new to java and am wanting to create a programe for the rhyme 10 green bottles. 10 green bottles standing on the wall 10 green bottles standing on the wall and if 1 green bottle should
New to Java?
by using a web browser. As we know Java applet can run in a browser but in case... New to Java?       If you are new to Java technology and you want to learn Java and make career
Code for opening a new mail from the default mail box and copy the database contents
Code for opening a new mail from the default mail box and copy the database contents  Guys, here is how it goes when i click on a button say "mail... respectively be fetched ,and my default mail should be opened and a new mail
The new keyword in java
The new keyword in java In this section you will learn about new keyword in java. The new keyword is used to create a instance of a class. The new keyword...;   A ob = new A(); While using  new  keyword some points
Opening files with .jnlp extension on browser!?!?!
Opening files with .jnlp extension on browser!?!?!  I working... for Runtime.getRuntime().exec("..........."); I came across the java code.... Rather i want to open it in my browser(Mozilla/IE) itself. Kindly provide me
changes in netbeans/ browser so that each application run opens in a new window of browser
changes in netbeans/ browser so that each application run opens in a new window... time i run an application it opens up in a new window rather than a new tab.. Do i have to make changes in netbeans or browser? and what changes need
im new to java - Java Beginners
im new to java  what is the significance of public static void main... for a java class to execute it as a command line application. public- It provide...- It specifies the return type. main- This method in java is designed
How to Create New Excel Sheet Using JSP
a new  excel sheet using java .You can create any number of  new excel... How to create new excel sheet using jsp  ... Jakarta(Jakarta POI - Java API To Access Microsoft Format Files ) Tomcat. You can
new String(text) - Java Beginners
(text): In this Case Java will create a new String object in normal (non-pool...new String(text)  Please, what is the difference between this.text = text; and this.text = new String(text); in the example: public
Java create new array of strings.
Java create new array of strings.  Java create new array of strings.   Example: public class StringArray { public static void main... (eg. int,char,float etc). For example String name[]=new String[7
Java new arraylist
Java ArrayList object is created with the reference of List interface Object is also created directly by the ArrayList class Java New Arraylist..."}; //ArrayList list=new ArrayList(); List list=new ArrayList(); list.add(ar[0
Advertisements
 

 

 

DMCA.com