aspose file tools*
The moose likes Servlets and the fly likes Most proper definition of a Session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Most proper definition of a Session" Watch "Most proper definition of a Session" New topic
Author

Most proper definition of a Session

Ylva Degerfeldt
Ranch Hand

Joined: Feb 12, 2008
Posts: 30
Hi,

I'm currently writing a thesis where a part of it should be some theory about Java EE 5, Servlets, JSPs and some related things.
My question now concerns sessions (server side sessions, web sessions or what ever they should be called).

I'm rather new to web programming but I think I know the most important parts of what a session is. I would like to know for Sure though what the right definition is, so I can write about it in my thesis.

I've tried searching the web, but I haven't found the answers to some specific questions:
1. Is a new session always started when a user is redirected to a page that belongs to a different application (even if that application runs on the same server as the first one)?
2. In servlets: In the common model where only One server instance exists; is it running one thread per session, always?

It would be great if someone just knows any good links to where I can find answers to these questions.

Thanks in advance,
Ylva
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The absolute best, bar none, place to look would be the servlet specification.
There is a link to the spec in my signature.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

1.) Yes sessions are per application. The user would have one session for each application, even if both applications are running on the same server.

2.) Not one thread per session. One thread per request.
Ylva Degerfeldt
Ranch Hand

Joined: Feb 12, 2008
Posts: 30
Thank you, Ben!

I started looking in the servlet specification and I found this under the HttpSession Interface specification:

"Session information is scoped only to the current web application"

I think that was kind of an answer to question 1 and then I have your answer as well. Thanks!

About the second question.. When I think about it some more, it's obvious that a session needs more than one thread for "all its business" but one thread per request sounds logical. (I could have figured that out myself if I had just trusted myself and my brain some more so Sorry for taking up your time with this question.)

/Ylva
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

No problem.
Good-luck with your thesis.
 
 
subject: Most proper definition of a Session