• Post Reply Bookmark Topic Watch Topic
  • New Topic

what is session and new request  RSS feed

Arun Maalik
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37252
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!