• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session in an application having html,servlets,Jsp

 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • 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
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use URL rewriting and set/get the necessary info into the session (getSession, session.setAttribute,session.getAttribute...).
 
Chetan Raju
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • 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
  • 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 ]
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case of cookies disabled , go for URL rewriting.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic