This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Request Dispatcher Behaviour Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Request Dispatcher Behaviour" Watch "Request Dispatcher Behaviour" New topic
Author

Request Dispatcher Behaviour

sriram sundararajan
Ranch Hand

Joined: Apr 08, 2003
Posts: 43
1. ServletContext context = config.getServletContext();
RequestDispatcher rd = context.getRequestDispatcher("/a/myServlet2");
rd.include(req,res);

/a/myServlet2 is not a valid url but rd.include() doesn't throw any exception why?

2. ServletContext context = config.getServletContext();
RequestDispatcher rd = context.getRequestDispatcher("/a/myServlet2");
rd.forward(req,res);

/a/myServlet2 is not a valid url but rd.forward() throws exception why?


ServletContext context = config.getServletContext();
try{
RequestDispatcher rd = context.getRequestDispatcher("/a/myServlet2");
rd.forward(req,res);
}catch(Exception e){
out.println("inside catch...");
}


I want to do exception handling but catch block is not executing why? i.e "inside catch..." is not getting printed in the browser why?
shiva viswanathan
Ranch Hand

Joined: Aug 12, 2004
Posts: 152
Hi,

Are you atleast getting a 404 not found error

I dont think so it throws an error
Its just that it will not be able to find the specified resource
amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
i think but not sure at all..just guessing
we must make isErrorpage=true which is false by default to include exception handling...


Thanks and Regards, Amit Taneja
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Request Dispatcher Behaviour