You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Dominique Deleris <do...@bluewin.ch> on 2002/08/03 22:00:33 UTC

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?

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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat4 and encodeURL

Posted by Dominique Deleris <do...@bluewin.ch>.
On Sat, 3 Aug 2002 13:44:42 -0700 (PDT), "Craig R. McClanahan" <cr...@apache.org> said:

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

 Craig> * There is actually a session in existence

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

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

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

Craig,

Thanks for your help. I was missing something : I had to
"encodeURL" a second URL, which was called under special
circumstances. Your remarks #1 and #2 reminded me of this.

Thanks for the whole explanation !

Kind regards,
-- 
Dominique Deleris
http://potatoworld.tuxfamily.org


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat4 and encodeURL

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On 3 Aug 2002, Dominique Deleris wrote:

> Date: 03 Aug 2002 22:00:33 +0200
> From: Dominique Deleris <do...@bluewin.ch>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: tomcat-user-list <to...@jakarta.apache.org>
> 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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>