I am running a servlet LoginServlet that calls another servlet, AccountServlet. Tomcat is unable to find the called servlet: AccountServlet when I call it from within LoginServlet. AccountServlet runs properly when I run it from the address bar, but as soon as I attempt to obtain a RequestDispatcher object using AccountServlet I get the unable to find Account Servlet error. Here is the code that is giving me problems: ServletContext ct = getServletContext(); RequestDispatcher rd = ct.getRequestDispatcher("/servlet/AccountServlet"); rd.forward( req, res ); Everything else is fine but I cant seem to get AccountServlet running. Should I specify a more specific path in my getRequestDispatcher method call?
I have not tried calling AccountServlet from the address bar yet. None of my servlets are in packages. My directory structure is as follows: webapps/bankingApp/web-inf/classes. AccountServlet and LoginServlet reside in the classes directory. The servlet is declared in my deployment descriptor is as follows: <servlet> <servlet-name>LoginServlet</servlet-name> <servlet-class>LoginServlet</servlet-class> </servlet> <servlet> <servlet-name>AccountServlet</servlet-name> <servlet-class>AccountServlet</servlet-class> </servlet> I have tried calling AccountServlet using RequestDispatcher rd = ct.getRequestDispatcher("/AccountServlet"); but still no luck. Thanks for all your responses.
In your first post, you said " AccountServlet runs properly when I run it from the address bar,", but never mind...
* WEB-INF , not web-inf (there's a big difference)
* please package your servlets
* read about servlet mappings, and USE them (please). read this entire FAQ Also in that document, you'll read about the invoker servlet (and why it's evil). [ December 09, 2003: Message edited by: Mike Curwen ]
Why is the word "abbreviation" so long? And this ad is so short?
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth