• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

RequestDispatcher URLrewrite SessionID

 
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 ?
 
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....
 
Ranch Hand
Posts: 101
  • 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.
 
I don't even know how to spell CIA. But this tiny ad does:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic