Forums Register Login

getRequestDispatcher problem

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
RequestDispatcher rd = ct.getRequestDispatcher("/servlet/AccountServlet");
try this :
RequestDispatcher rd = ct.getRequestDispatcher("/AccountServlet");
+Pie Number of slices to send: Send
ur code is perfect.i think some problem with ur AccountServlet.u check whether u declared correctly ...
+Pie Number of slices to send: Send
how do you call it from the address bar ?
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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 ]
What's that smell? I think this tiny ad may have stepped in something.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1600 times.
Similar Threads
Servlet URL repeating
Session Tracking in Websphere
rd.forward()
getNameDispatcher()
prb from Hemant Deshmukh...
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:08:28.