aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Request Dispatching Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Request Dispatching" Watch "Request Dispatching" New topic
Author

Request Dispatching

bhushana rao
Greenhorn

Joined: Jun 02, 2008
Posts: 25
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

Joined: Feb 28, 2007
Posts: 1707
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.


cmbhatt
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707

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


See this link: quite explanatory
bhushana rao
Greenhorn

Joined: Jun 02, 2008
Posts: 25
thank you very much
it is really good to understand
vmbhatt





bhushan
scjp
scwcd preparing
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
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


SCJP, SCWCD, SCBCD
 
 
subject: Request Dispatching