• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RequestDispatcher URLrewrite SessionID

 
Edwin Jansen
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How should I handle URL rewriting to support non-cookie session-IDs with a requestdispatcher.

I've been testing with:


But that did not what I expected.

One other thing:
When to use and when ?
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I know you do not need to use url-rewriting if you are dispatching it.
response.encodeUrl()

response.encodeRedirectUrl()

As those methods are deprecated in j2ee 1.4 you should use response.encodeRedirectURL() and response.encodeURL() instead.

response.encodeUrl() is used for encoding urls (refer page 236 of HFSJ)and
encodeRedirectURL()is used when you wan't to redirect( You have to first encode it and then you have to redirect it)
Purpose of encoding is to add jsessionid in it and to encode unsafe characters.
 
Edwin Jansen
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dilshan Edirisuriya:
As far as I know you do not need to use url-rewriting if you are dispatching it.


Can anyone confirm that.

About the depricated function...I made a typo and was aware of it....
 
giuseppe fanuzzi
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in order to use url rewriting with dispatcher then you've to do this:

RequestDispatcher dispatcher = getServletContext().getRequestDispatcher (resp.[b]encodeRedirectURL(url)[b]);
dispatcher.forward(req, resp);
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it required to encode urls when you are dispatching?
In HFSJ they haven't explicitly said that
 
Edwin Jansen
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No it is not required, but when cookies are disabled by the client, you might not be able to use sessions.
The encodingUrl functions takes care of adding the sessionId as parameter to the URL.

You should not confuse it with URLEncoding (java.net.URLEncoder) where unsafe characters translated.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic