• Post Reply Bookmark Topic Watch Topic
  • New Topic

HTTPSession with URL Re-Writing  RSS feed

 
Sumit Tiwari
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,

I have used HTTP Session object to store the information of the name of the customer in one of my application, which display the user name at every pages.Now in between when i clear my cookies the name disappear.As I am beginner for SERVLET / JSP and referring HFSJ book. I have read that HTTP Session uses cookie for handling the session only if cookie is enable at client side ,while if it is disable we have to do a little extra work using URL re-writing .In my code, I used sendReDirect(jspPage) method to send the response to JSP page, but when cookie is disabled then its not working so I have changed it to encodeReDirectURL(jspPage). But still user name is not coming. May be I am wrong but it is any more extra work needed to do when the cookies is disabled or only this is enough. When I debug the code I found that class editor says like servlet-api.jar need source.

Any Suggestion.
 
Baseet Ahmed
Ranch Hand
Posts: 225
Java Notepad Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sumit,

As you are redirecting to move to jsp page, your session data will not be available, you can use forward instead to redirect to jsp page.

Dont depend on Cookies as it can be disabled at client side (browser). So instead of URL rewriting go with HttpSession mechanism for storing and sharing information.


--------
Regards
Ahmed
 
Sumit Tiwari
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Baseet Ahmed !!!

Now I have a doubt. Is HTTP Session internally uses cookies for storing and sharing information ? As I am using HTTP Session object to create a session but its not work when the cookie is disable at client side.Any other methodology to create session that will not depend on client side cookies.

Kindly explain this.
 
Baseet Ahmed
Ranch Hand
Posts: 225
Java Notepad Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This very much depends on the servlet engine.
Sometimes sessions are stored only in memory, in a HashSet of session IDs and the HttpSession.
Some servlet engines support serializing session information to a file system or database, which allows the servlet engine to restart without losing session information.

I am not sure but I found that HttpSession internally uses Cookies and if it is disabled then uses URL rewriting.


--------
Regards
Ahmed
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!