"Sharan, Abhishek" wrote:

>
>
> Hi Craig
>
>      -----Original Message-----
>      From:   Craig R. McClanahan [SMTP:[EMAIL PROTECTED]]
>      Sent:   Thursday, June 01, 2000 9:16 PM
>      To:     [EMAIL PROTECTED]
>      Subject:        Re: retrieving http session
>
>      "Sharan, Abhishek" wrote:
>
>      > hi anshul
>      >
>      > get a reference to HttpSessionContext object and call
>      getSession( with
>      > sessionid as parameter)
>      > pls go thru the api before posing such kind of newbie query
>      > thanks
>
>      This will only work if your servlet container implements the 2.0
>      version
>      of the servlet API -- not 2.1 or 2.2.  In the later versions,
>      there is
>      no mechanism that allows a servlet to retrieve a session  by ID.
>
>      This means that you must either rely on the container's
>      implementation
>      of session support,
>
>       could you please give some insight as to how to go about it if
>      somebody goes for this option
>
>
Simply follow the instructions for using sessions that you will find in
any book or tutorial about servlets.

Basically, what that means to a servlet developer is:

* In your doGet() or doPost() method, call:

    HttpSession session = request.getSession(true);

  to create a new session if it does not exist, or

    HttpSession session = request.getSession(false);

  if you only want an existing session if there is one.

* If you need to run on browsers that do not support cookies,
  you must use URL rewriting on all your hyperlinks.  For example:

    writer.println("<a href=\"" +
      response.encodeURL("/servlet/MyServlet") + "\">My link</a>");

>
>      you must completely replace it with your own
>      mechanism.
>
>      > Abhishek Sharan
>
>      Craig McClanahan
>
>
Craig McClanahan

___________________________________________________________________________
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

Reply via email to