Hi David,
This is an excerpt from the sun servlet tutorial.
Handling All Browsers
By default, session tracking uses cookies to associate a session
identifier with a user. To also support users that
access a servlet with a browser that does not support cookies, or
that is set up to reject cookies, you must use
URL rewriting instead. (While some web servers support URL rewriting,
the servletrunner utility does not.
For session tracking to work when a servlet is running within
servletrunner, the user agent must support
cookies.)
When you use URL rewriting you call methods that, when necessary,
include the session ID in a link. You must call
these methods for every link in the servlet response.
The method that associates a session ID with a URL is
HttpServletResponse.encodeUrl. If you redirect
the user to another page, the method to associate the session ID with
the redirected URL is called
HttpServletResponse.encodeRedirectUrl.
The encodeUrl and encodeRedirectUrl methods decide whether the URL
needs to be rewritten, and return
the URL either changed or unchanged. (The rules for URLs and
redirected URLS differ, but in general if the
server detects that the browser supports cookies, then the URL is not
rewritten.)
If the user clicks on a link with a rewritten URL, the servlet
recognizes and extracts the session ID. Then the
getSession method uses the session ID to get the user's HttpSession
object.
On the other hand, if the user's browser does not support cookies and
the user clicks on an un-rewritten URL, the
user's session is lost. The servlet contacted through that link
creates a new session, but the new session does not
have the data associated with the previous session. Once a servlet
loses the session data, the data is lost for all
servlets that share the session. You should consistently use URL
rewriting if your servlet is to support clients
that do not support or accept cookies.
Hope this helps.
Bye.
-Kiran.
David Galimberti wrote:
> I am having problems with session managment for a servlet that is the
> src of an HTML img tag, for example: <img
> src="/servlet/imageServlet"> Prior to using the servlet I created a
> session for the user but the servlet does not find one for the request
> (i.e. request.getSession(false) returns null). If I access the
> servlet via a redirect I can get to the session just fine. Does anyone
> know if there is something "special" about a request of a servlet that
> is the src of an img? Thanks! - David
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html