• Post Reply Bookmark Topic Watch Topic
  • New Topic

getting servlet name from request?  RSS feed

Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Manning''s book it is said that if you forward a request to an error page using a RequestDispatcher (which is not recommended), that you have to set some attributes in the request (what the servlet container would otherwise take care of). It also sais that you can get the servlet name from the request by calling req.getServletName(). But I don't understand this, because getServletName() is a method of ServletConfig, not of HttpServletRequest. Is this an error in the book or am I not understanding it? This is the code fragment:
double newBalance = debit(accountId, amount);
catch(InsufficientFundsException isfe)
req.setAttribute("javax.servlet.error.exception", isfe);
RequestDispatcher rd = req.getRequestDispatcher( /servlet/BusinessLogicExceptionHandlerSerlvet");
rd.forward(req, res);
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!