• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session Tracking

 
Java Green
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does a web container tracks the session if the client doesn't support cookies. We know that encodeURL() method is helpful in URL Rewriting, but everything that a web container sends response to the client need to be generated dynamically. How could we overcome this problem.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can do it on server side using DB or some file.
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

url rewriting technique works well for dynamic pages. It will not work for static html pages. If performance is not one of the major concerns(Which usually is ).. try to use hidden form fields for session tracking..

cheers,
Neeraj.
 
Java Green
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi neeraj,

"Hidden form fields" means of sesion tracking can be done only when the output generated by the web container contains forms and even they need to be generated dynamically. I want a solution taht works fine for static pages also.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
put an attribute in your HttpSession.

request.getSession().setAttribute("sessionId", sessionId);
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


unless you have combnation of html pages with servlets/jsp/ any other server side concepts..I don't think plain HTML pages can maintain a state.


Regards,
Neeraj.
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has anybody got solution for the Java Green's problem ?

Neeraj.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13077
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you can't support cookies and you can't support URL rewriting, and you can't use hidden variables in forms there is NO way that a servlet can reliably track a user. The basic HTTP request / response cycle is stateless.
Bill
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
URL rewriting is the only thing that comes to mind. And that might well require a servlet to start and maintain the session.
In case all content is purely static that servlet would then just sit there and forward requests to the requested page after doing its job of checking whether the session is alive and if not creating it.

What good that would do is rather dubious of course, all it'd do IMO is eat server resources with no return.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Java Green"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thnx for the inputs.

Neeraj.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic