File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Session Variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Session Variables" Watch "Session Variables" New topic

Session Variables

Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
how the server will know whether this session is belongs to usr1 or usr2 in the request......How the URL rewriting works with a session.

Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Every time a session is created there is a unique session id created by the container and sent to the browser that originated the request that created the session. So if you have two users they would each get their own session id and then every time they request a resource from that application the container gets the session id from the cookie that is stored on the users computer.
URL rewriting is used for when cookies are disabled, it works by taking any URLs sent back to the client and appending the session id to it, that way the session id is part of any request sent by the browser to the container.
Does that help, if you need a more detailed explaination let me know.

Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
Thanks Dave
varun bihani
Ranch Hand

Joined: Aug 11, 2003
Posts: 96
The more simple method I guess would be assign a unique ID for each user to the particular name and setting its session attribute like this..
and then getAttribute like..
String userid=(String)session.getAttribute("userid");

<a href="" target="_blank" rel="nofollow"></a><br /><a href="" target="_blank" rel="nofollow"></a><br /><a href="" target="_blank" rel="nofollow"></a>
I agree. Here's the link:
subject: Session Variables
It's not a secret anymore!