• Post Reply Bookmark Topic Watch Topic
  • New Topic

How does servlet container choose tracking method  RSS feed

 
Elizabeth King
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sending a HTTP request with this URL from my browser: http://mywebsite.com/myapp/welcome.do?name=jim

How does servlet container know which session tracking methods (Cookies, URL Rewriting, or Hidden Field)
to use to track my session initially? My URL does not tell any
information about the cookies.
Any tricks the servlet container has to play?
 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

When you use URL re-writing, and for the first time, the container will send the session id with the URL, as well as a cookie with the response, next, when the user makes another request, the container will check, if there's a cookie with the request it will use cookies, otherwise (the user has disabled the cookies) the container will use URL re-writing.

Best of luck ...
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the container will use URL re-writing.


A common misconception. It is up to the programmer, NOT the container to use URL re-writing. Think about it, how can the container know which of the many URLs in a HTML web page should be modified.

Bill
 
Glen Cai
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by William Brogden:


A common misconception. It is up to the programmer, NOT the container to use URL re-writing. Think about it, how can the container know which of the many URLs in a HTML web page should be modified.

Bill


As long as URLEncoder is used for all the URLs, URL Rewriting should work
fine.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As long as URLEncoder is used for all the URLs, URL Rewriting should work


Lets review the APIs:

java.net.URLEncoder is used to put arbitrary text into a URL in a form that HTTP will be happy with.

The HttpServletResponse method encodeURL() uses the information available about whether or not the user's browser supports cookies, and if a session is in use, to encode the sessionID into a URL if necessary. Again - applying this method to URLs when writing a HTML page is not automatic, the programmer must write the code.

Bill
 
Suman Sharma
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the cookie is disabled on client's machine, what kind of error the servlet container gives that makes us use the URL re-writing mechanism to send the response?
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Suman Sharma:
If the cookie is disabled on client's machine, what kind of error the servlet container gives that makes us use the URL re-writing mechanism to send the response?


No error message involved. First time the server tries to track the session using cookies and URL rewriting and after the first response from the client , the server can figure out whether the clients cookies are disabled or not and proceeds further.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In response to the original question.
The spec leaves a lot of this up to the container developers.
For Example:


SRV.7.1.2 SSL Sessions
Secure Sockets Layer, the encryption technology used in the HTTPS protocol, has a
built-in mechanism allowing multiple requests from a client to be unambiguously
identified as being part of a session. A servlet container can easily use this data to
define a session.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!