File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes what is session and new request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "what is session and new request" Watch "what is session and new request" New topic

what is session and new request

Arun Maalik
Ranch Hand

Joined: Oct 25, 2005
Posts: 216
Dear sir

I would like to know what is session. when does it created, when it is destroyed. also i would like to know that when a new request is created for a page.

well supose i have created a LoginUser.html page in within context root newctx which accept userId and password as the name sugest for this page then i will request for that page as bellow...


Now if i am not wrong then i think at this time i am requesting for the page LoginUser . Now further if i will eneter wrong password two or three time then that password will be validiated by server then at this time what happen ?

if i will enter wrong password then will a new request will created for this page or not? In this case when will seesion created or when will destroyed. please specify me i am getting confuge about session and request.

with reagrd

Arun kumar maalik
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33132

A new request is created every time the browser submits a page. A new request would be created for each time the user entered the wrong password, since it is independent of data.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

A session, or more accurately, an HttpSession, is probably the most important object in the entire Servlet API. Its importance cannot be understated.

First of all, an HttpSession object has nothing to do with a Session EJB, so let�s get that association out of your mind right away. It is a completely different monster. An HttpSession is a server-managed component completely independent of the EJB spec.
The Session Issue

Here�s the issue: the http protocol, the mechanism we use to surf the Internet and browse websites, is stateless. Once a Web server is done handling a client request, the web server completely forgets about what it just did, kinda like that fish in Finding Nemo.

The http protocol treats every request as a brand spanking new, unassociated request, regardless of how many client-server interactions may have happened with a particular client in the past.

A web server, using the http protocol, doesn�t maintain any meaningful state with a client.

A stateless protocol, such as http, causes all sorts of problems for our web-based applications. For example, if someone surfs to our site and sees a product they want to buy, we want to keep track of that information until the user decides to check out.

Or perhaps a user is taking an online exam: we would want to keep track of every answer the user has provided. The http protocol provides no mechanism for keeping track of a user�s actions from one invocation to the other. That�s where the Servlet API, and more specifically, the HttpSession, comes in.

Here's some more information:
[ August 27, 2006: Message edited by: Bear Bibeault ]
I agree. Here's the link:
subject: what is session and new request
It's not a secret anymore!