This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Request Dispatching

 
bhushana rao
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai javaranches

can we use sendRedirect() of HttpServletResponse to
redirect to servlet or
it is for only to redirect to html or jsp files
what is defference between
RequestDispatcher() of ServletRequest
RequestDispatcher() of ServletContext

bhushan
scjp 98%
scwcd preparing
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sendRedirect() means to tell the browser with status code that it needs to
request again for another servlet or jsp resource. Browser history is
also maintained in this case because browser will automatically hit a new
request here and you know that because the URL @ address bar is changed.

In other words, suppose you have one resource on server named a.jsp,
but at some point of time, a.jsp is made obsolete or no longer available
on the server. But to let not user request go for 404 (page not found)
you may follow send redirect assisting the browser to hit for another
page named a1.jsp or any servlet in place of a.jsp because as said its no
longer available.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

what is defference between
RequestDispatcher() of ServletRequest
RequestDispatcher() of ServletContext


See this link: quite explanatory
 
bhushana rao
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you very much
it is really good to understand
vmbhatt





bhushan
scjp
scwcd preparing
 
Deepak Jain
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we use sendRedirect() of HttpServletResponse to redirect to servlet or
it is for only to redirect to html or jsp files.


It can be used to redirect to any resource that is defined in the WEB.xml.
a) When you specify a JSP , web container will directly get that resource.
b) If you specify a URL pattern then web container will use web.xml to decode the url pattern to a servlet or a JSP file [In case there is a servlet mapping with jsp-file].
Try these out , they are quite interesting.

Have a look at ServletContext.getNamedDispatcher() as well
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic