This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Request Dispatcher Behaviour

 
sriram sundararajan
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think but not sure at all..just guessing
we must make isErrorpage=true which is false by default to include exception handling...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic