• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HTTPSession with URL Re-Writing

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 225
Spring Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Spring Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
What a show! What atmosphere! What fun! What a tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic