This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes getting servlet name from request? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "getting servlet name from request?" Watch "getting servlet name from request?" New topic

getting servlet name from request?

Carlo Smits

Joined: Jul 09, 2001
Posts: 22
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);
I agree. Here's the link:
subject: getting servlet name from request?
It's not a secret anymore!