• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

clarification in the parameter of response.sendRedirect and request.getRequestDispatc

 
preeti venugopalan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Errata of HFSJ says that if a "/" is given in the begining of the string url parameter of the sendRedirect then the path is taken from the begining of the web container
for eg if the original request url is http://www.wickedlysmart.com/myapp/cool/bar.do
and the sendRedirect is given as sendRedirect("/foo/stuff.html");
then the container builds the complete url relative to the web container..so the new url is
http://www.wickedlysmart.com/foo/stuff.html

wherelse if the url string parameter given in the RequestDispatcher begins with "/"
then the container sees it starting from the root of the web app...
isn't it confusing..why such a discrepancy?
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 2 ways to obtain a reference to a RequestDispatcher. If you consider the one you get from the ServletContext, it may make more sense...
 
preeti venugopalan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael...that makes sense
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic