Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session, a quick question

Status
Not open for further replies.

Swede

Programmer
May 17, 2001
6
US
Hello,

I have to handle sessions with my servlet. No problem as long as the client accept cookies, but if it doesn't. How can i keep the session anyway? Any tips would be appreciated.

// Daniel
 
If there is no session in the cookie, the servlet engines are searching it in the url. In this case yue may use the url rewriting. You must get/put the session id from/into the url. See the encodeURL() and getRequestURI() methost of the HttpServletRequest class.

Good luck. Bye, Otto.
[sig][/sig]
 
Hi again Otto,

Thanks for helping me out. Seems like you are the only one responding to my posts. ;-) Thanks for the tip, I heve tried to use that method, but i does not seem to work. However it might be me just calling it the wrong way or something.

One other thing that strikes me though is that you never use jusr hyperlinks on a site. Use have to have forms for those passwords and so on. So, how do you do to keep the session when calling with a form, and cookies turned off?

Would appreciate any reply.

// Daniel
 
This is a big problem. I have thought a lot of it, and make a solution (my solution :)).
Before the login I do not care with the session. After the login I put the session id into the url (like - I use apache with JServ). I made a servlet, and when the user ask a page, this servlet give the page, and fill all links and other things in the page (this page is like a template), put the active (if it is exist) session id into every url (img src, href, etc.). Thus all link will be in the same session. It was a little hard, but today it is working well.

I hope this will help you, and you understand me, but please, excuse my English.

Bye, Otto.
[sig][/sig]
 
This is a big problem because then every page in your site would have to be a servlet. I ran into this a while back and couldn't figure out any way to deal with it except to go to jsp.

For example suppose you have fifty pages in your site and only five or six require servlet output. The remaining pages (if they were HTML) would lose the session ID. If most of the HTML pages are similar then you can create somekind of servlet template for them just for the purpose of maintaining session. But that gets impractical because there's usually somebody involved other than you who just wants to make HTML changes and doesn't know anything about java.

So it seems like jsp is a better way to deal with this because you can separate HTML from java code (almost entirely if you want) but it's definitely a issue.

For example, if you go to sears.com (which is a jsp site) you'll see that every page is a jsp page and that every page has the session id in the url.

[sig]<p>--Will Duty<br><a href=mailto:wduty@radicalfringe.com>wduty@radicalfringe.com</a><br><a href= > </a><br> [/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top