#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    2
    Rep Power
    0

    Javascript corrupt my JSP session


    when I do a location.replace or location.href, my jsp session id is changed to another one. And I can't stop that from happening.

    Anyone can suggest a solution here.

    I am using a button to prompt for a function containing the location.replace

    thanks for any help
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    Your session should only get replaced if you are changing the domain name in the url. If you are using a relative url when assigning the href, the session should not be changed.

    We ran into a similar problem when we were developing a site. A box had two domain names that were similar and either would work to access the site. A coder had inadvertantly used the non-standard name in a link and it was creating a new session, even though it was the same server. Hope that makes sense...
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    2
    Rep Power
    0
    Originally posted by Nemi
    Your session should only get replaced if you are changing the domain name in the url. If you are using a relative url when assigning the href, the session should not be changed.

    We ran into a similar problem when we were developing a site. A box had two domain names that were similar and either would work to access the site. A coder had inadvertantly used the non-standard name in a link and it was creating a new session, even though it was the same server. Hope that makes sense...
    Hi,

    In my case, I'm only redirecting the user to another jsp page located in the same folder. Refer to here

    for a more comprehensive description of the problem.

    I would also greatly appreciate if you would give me examples.....you are my only hope now...
  6. #4
  7. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    Hmm, do you HAVE to use location.replace? Normally, when I have a button act like a link in javascript I just assign the location object the new url:
    Code:
    location = "newPage.jsp";
    This causes the page to make a request for the new page on the same host because I left off the protocol and host name. Used this way it should function identically to a clicked link on a page.

    I have to admit I have never used location.replace. replace is specifically used to replace a page in the users history, making navigating back to the page by using the back button impossible. Not having used it, I cannot say if there would be some quirk with it I am not aware of.

    EDIT: just for kicks, replace the button with a link that goes to the same page and see if you still have your problem.

    EDIT2: Also, I believe that encoding the session ID in the url only works if the servers session handler has URL Rewriting turned on, which I don't think most do by default. This is in reference to something that was posted ont he other MB.
    Last edited by Nemi; June 4th, 2002 at 07:04 PM.

IMN logo majestic logo threadwatch logo seochat tools logo