• Post Reply Bookmark Topic Watch Topic
  • New Topic

Session ID changing within session

 
Fred Rogan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am having a problem where the session id is changing (sometimes) after submitting a form to a servlet and responding to another page.

My jsp page has a html form with action="servlet/FCSpinalMuscularSurvey"

The servlet code is as follows:
public class FCSpinalMuscularSurvey extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{

response.setContentType("text/html");
String sNextPage = "/Page2.htm";

if (!sNextPage.equals(""))
{
response.sendRedirect(sNextPage);
}
}
}

When I try to get the session id from Page2.htm it has changed.

Has anyone else experienced this problem.

The code is redirecting properly just changing the session id. If I press refresh on the browser and try the same sequence there is no problem ie. the session id doesn't change. Any ideas would be great.

Cheers,
John
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I try to get the session id from Page2.htm it has changed.

If you see a different session id, you have a different session object. There is no way for your code, or normal servlet container code to change the id, thats the whole idea.
Bill
 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it because your session has timed out while waiting for you to fill in the form?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"John van H",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
Fred Rogan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The form is not timing out and changing session.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"John van H/Rid Appetit",

Perhaps you missed the "not obviously fictitious" part of the naming convention. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

Your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

bear
JavaRanch Sheriff
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Rid Appetit"

Please see Bear's previous post about 'fictitious names'

Thanks,
Dave.
 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The form is not timing out and changing session


And, are you sure you've turned on cookie support in the browser?
 
Fred Rogan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cookie support is on but I wouldn't of thought this would affect the session state anyway.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Fred Rogan:
Cookie support is on but I wouldn't of thought this would affect the session state anyway.


How do you think the session is maintained?
 
Fred Rogan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After restudying the topics about session state/cookies etc I realised you guys may have a point. So I disabled my firewall which I thought was not affecting my cookies because of my settings. However this fixed the problem.

Thanks guys for putting up with my ignorance.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!