Alexandre Vermeerbergen wrote:
> I agree with this answer, but to be crude : "how to do read the session
> cookie id and how to do send it back to the app server?"
> I know that at server-side you have such manipulation methods in
> javax.servlet packages ; but how about at a client Java application side?
> URL and UDLconnexion classes do no seem to have anything related to
> cookies. Additionnaly, it seems that each application server has its own
> name for the session id cookie (Servlet2.2 specs are supposed to normalize
> that by calling the session id cookie 'jsessionid').
> Alex.
>
URLConnection supports the setRequestProperty() method to set arbitrary
headers in the outbound request message, and the getHeaderField() family of
methods to iterate through the received headers in the response. You could
also use the getRequestProperty() method when processing the response, but
this can fail if the response contains more than one cookie.
So, you will need to format your own cookies in the request (and parse them in
the response) according to the cookie specification (RFC 2109, which is
available among other places at http://www.rfc-editor.org). If you don't want
to build this code yourself, you might want to grab one of the open source
servlet engine implementations (such as Apache JServ) and look at the code
that the servlet engine is using for this.
For the cookie name, you're going to have to make your app configurable based
on the characteristics of the server you are talking to, until the engines all
support the 2.2 standard name. I would suggest passing some sort of
initialization parameter to your application or applet that says "when I am
talking to server X, the session ID cookie name is Y".
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