• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getting servlet name from request?

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
try
{
double newBalance = debit(accountId, amount);
}
catch(InsufficientFundsException isfe)
{
req.setAttribute("javax.servlet.error.exception", isfe);
req.setAttribute("javax.servlet.error.request_uri",
req.getRequestURI());
req.setAttribute("javax.servlet.error.servlet_name",req.getServletName());
RequestDispatcher rd = req.getRequestDispatcher( /servlet/BusinessLogicExceptionHandlerSerlvet");
rd.forward(req, res);
Carlo
reply
    Bookmark Topic Watch Topic
  • New Topic