• 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

Session in an application having html,servlets,Jsp

 
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a web application having servlets,jsp,html pages....

Scenario 1:

How can i guarantee session across the application,if the user moves

across jsp pages ,servlets and html pages ..?

Scenario 2:

If cookies are disabled then?

Thanks in advance,
Regards
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use URL rewriting and set/get the necessary info into the session (getSession, session.setAttribute,session.getAttribute...).
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use

1. URL Rewriting
2. HTTP Session API
3. Form Based
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the quick response...

But if the cookies are disabled...then will the html pages cause a problem if i go for URL rewriting...

in terms of keeeping the session intact

Regards
[ September 27, 2006: Message edited by: A Kumar ]
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In case of cookies disabled , go for URL rewriting.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Raul mentioned.
If cookies are disabled, you'll need to use URL Rewriting.

If this is the case, you'll need to convert all of your HTML pages to JSPs so that you can embed the sessionId into all of the URLs used in anchor tags and form actions.

[correction]
You'll need to convert any HTML pages that have links or forms to JSPs.
[ September 27, 2006: Message edited by: Ben Souther ]
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You'll need to convert any HTML pages that have links or forms to JSPs.




This is the clarification I needed .....

Regards
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to rewrite the jsp and servlet using some different set of methods which incluses the jsessionid after the url.All the hrefs in your jsps will also change.

Lots of online materials are also available describing this method.even Head first book on servlets and jsp has delt with this , in the session tracking chapter.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Rahul...

You need to use encodeURL(...)

but I was concerned about the HTML pages in such an evironment...

Regards
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can think of two things in this regard,

Basically session is tracked using JSESSIONID in cookies and cookies which traverses to and fro in the header of the HTTP request and responses.So in case the html is forward by a servelt then the header of the HTTP response that has the html would also contain the JSESSIONID.In that way the session can be tracked for html pages.

Or,

you have append every anchor tag's href attribute with something like
;JSESSIONID=<sessionID> to maintain the session for html pages.

I think this needs a lot of work.Prefered way would be to certify your application for browsers with cookies enabled.this way you can reduce a lot of work.
 
reply
    Bookmark Topic Watch Topic
  • New Topic