Results 1 to 6 of 6
  1. #1
    nn12 is offline Member
    Join Date
    Sep 2008
    Posts
    85
    Rep Power
    0

    Default Question about browser sessions

    In a java web app, if I am browsing a site and then I open another IE 8 window* and go to the same site, is there a way to detect that the request has come from another window from the same machine.

    Basically my requirement is to alert the user that they cannot open another window with the same site.

    *In IE 8 all windows share the same session. Hence request.getsession() would always return the same ID across all the windows.

  2. #2
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default

    it depends of your application. How you managed to sessions inside.
    Skype: petrarsentev
    http://TrackStudio.com

  3. #3
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default

    You could include some random and otherwise meaningless ID in the URL and pass it around from page to page. If you see two different IDs associated with the same session, you'll know there are (or were) two different windows opened. Then you could, say, display an error in response to subsequent page loads using the old ID.
    Get in the habit of using standard Java naming conventions!

  4. #4
    nn12 is offline Member
    Join Date
    Sep 2008
    Posts
    85
    Rep Power
    0

    Default

    @knkrum - can you pls tell me how to append a number to an URL or refer me to some site. I am basically using struts 1.3 application

  5. #5
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default

    Sorry, it's been a long time since I did any Web development. But I would probably add parameters to my URLs using PHP, not Java.

    If by Web app you mean an Applet, you can try using Applet.getDocumentBase() to get the URL. But I'm not sure if that will include the parameters.
    Get in the habit of using standard Java naming conventions!

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,390
    Rep Power
    25

    Default

    When you build the HTML page add a parameter to all the tags: <A href="http://www.java-forums.org/new-java/ ... +ID=newIdXXX ..."

    Not sure of the syntax of the URL. I used a + to delimit the items

Similar Threads

  1. sessions
    By murali23krishna in forum New To Java
    Replies: 1
    Last Post: 05-17-2011, 11:56 AM
  2. Sessions
    By Billywizz in forum New To Java
    Replies: 1
    Last Post: 03-28-2011, 08:53 PM
  3. Sessions in jsp
    By Ed in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 07-02-2007, 03:46 PM
  4. sessions in jsp
    By Heather in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 06-30-2007, 03:44 PM
  5. Sessions and logout question
    By orchid in forum Web Frameworks
    Replies: 1
    Last Post: 05-18-2007, 06:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •