Tomcat4 and encodeURL

2002-08-03 Thread Dominique Deleris

Hi !

I'm new to J2EE, and therefore I am trying each and every example
of the programming book I've bought.

Now I am learning session handling w/ the servlet API, and would
like to use the URL-encoding style for keeping sessions, when the
browser's configuration does not allow to use cookies.

My (simple) example servlet is using the following instruction:
  String lifeCycleURL = response.encodeURL(/jtests/servlet/lifeCycle);
  out.println(A href=\ + lifeCycleURL + ?action=newSession\);

This should modify my URL, adding ;jsessionid=xxx where xxx is
the session ID. I can not get this to work, Tomcat will only
handle sessions using cookies...

Maybe I'm missing something?

I use :
Tomcat 4.0.4
Apache 1.3.26
mod-jk
Debian Woody (3.0)

-- 
Dominique Deleris
http://potatoworld.tuxfamily.org


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Tomcat4 and encodeURL

2002-08-03 Thread Craig R. McClanahan



On 3 Aug 2002, Dominique Deleris wrote:

 Date: 03 Aug 2002 22:00:33 +0200
 From: Dominique Deleris [EMAIL PROTECTED]
 Reply-To: Tomcat Users List [EMAIL PROTECTED]
 To: tomcat-user-list [EMAIL PROTECTED]
 Subject: Tomcat4 and encodeURL

 Hi !

 I'm new to J2EE, and therefore I am trying each and every example
 of the programming book I've bought.

 Now I am learning session handling w/ the servlet API, and would
 like to use the URL-encoding style for keeping sessions, when the
 browser's configuration does not allow to use cookies.

 My (simple) example servlet is using the following instruction:
   String lifeCycleURL = response.encodeURL(/jtests/servlet/lifeCycle);
   out.println(A href=\ + lifeCycleURL + ?action=newSession\);

 This should modify my URL, adding ;jsessionid=xxx where xxx is
 the session ID. I can not get this to work, Tomcat will only
 handle sessions using cookies...

 Maybe I'm missing something?


Tomcat (or any other servlet container) will actually modify the URL only
under the following circumstances:

* There is actually a session in existence

* The URL you are encoding points back into the same webapp

* The container knows that cookies are not in use (because
  this is not the first request for the session, and we got
  the session id from the URL previously.

In your particular example, encoding would only take place if the context
path of your application is jtests.  In addition, you must have called
request.getSession() to create the session *before* executing the
encodeURL call.

 I use :
 Tomcat 4.0.4
 Apache 1.3.26
 mod-jk
 Debian Woody (3.0)

 --
 Dominique Deleris
 http://potatoworld.tuxfamily.org



Craig


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]