• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sendRedirect :(

 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does it throw a IllegalArgumentExcpetion if the relative URL cant be converted to a absolute URL ???

one more thing ... i never knew that encodeREdirectURL( ) does just plan URL encoding, and it doesnt do any redirect ? is it ok ? this is what ths spec says -

Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged. The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL

also it says -

All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies

this means you should do

response.sendRedirect(response.encodeRedirectURL("...."));

tell me why the name encodeRedirect .. if it doesnt do any redirecting ? i mean if we already have the encodeURL for session management, why to have encodeREdirectURL ???

1. also why is it called endoeRedirect..if it doesnt do any redirecting ??
2. does sendRedirect throw a IllegalArgumentExcpetion if the relative URL
cant be converted to a absolute URL ???

please help out !

thanks in advance
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This means you should do response.sendRedirect(response.encodeRedirectURL("...."));

Yes. It will encore the url appropriately before passing it to sendRedirect.

1. also why is it called endoeRedirect..if it doesnt do any redirecting ??

Because it is used with sendRedirect.
There's also encodeURL, but the rules for setting the SESSIONID to the url seem to be different when used with sendRedirect.

When using URLs :
sendRedirect -> encodeRedirectURL
all other cases -> encodeURL

2. does sendRedirect throw a IllegalArgumentExcpetion if the relative URL cant be converted to a absolute URL ???

I don't understand why you're talking about relative to absolute conversion ?
encodeRedirectURL will only encode the url and add the SESSIONID if needed.
 
VijayKumar Sivagnanam
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does it throw a IllegalArgumentExcpetion if the relative URL cant be converted to a absolute URL ???


The spec says:


If a partial URL is given and, for whatever reason, cannot be converted into a valid URL, then this method must throw an IllegalArgumentException.

if the given url cannot be converted to a valid URL by the container, it must throw an IllegalArgumentException.
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic