This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Servlets and the fly likes path for forward()'ing to another servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "path for forward() Watch "path for forward() New topic
Author

path for forward()'ing to another servlet?

sven studde
Ranch Hand

Joined: Sep 26, 2006
Posts: 148
Hi,

In my servlet, I'm using the request object to obtain a RequestDispatcher. I can successfully forward() the request to a jsp page, but I can't seem to forward() to another servlet. Is that possible?

Here is my directory structure:

My form:

C:\jakarta-tomcat-5.5.9\webapps\ATest1\form.htm

which calls TestServlet:

C:\jakarta-tomcat-5.5.9\webapps\ATest1\WEB-INF\classes\TestServlet.class

and in TestServlet, I am trying to forward to ServletB:

C:\jakarta-tomcat-5.5.9\webapps\ATest1\WEB-INF\classes\pack1\ServletB.class

I've been trying to use an absolute path that starts with a '/':

RequestDispatcher servlet2 = request.getRequestDispatcher("/pack1.ServletB");
servlet2.forward(request, response);

but I get an error that says:

type: Status report

message: /ATest1/pack1.ServletB

description: The requested resource (/ATest1/pack1.ServletB) is not available.


I've tried other paths, but I can't seem to get anything to work.
[ November 01, 2006: Message edited by: sven studde ]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Use the mapping associated to ServletB (in web.xml), not the full qualified path to the class file.


[My Blog]
All roads lead to JavaRanch
sven studde
Ranch Hand

Joined: Sep 26, 2006
Posts: 148
Thanks. I got it to work.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: path for forward()'ing to another servlet?
 
Similar Threads
JSP can't find bean classes
Problem getting Resin to recognize servlets under ROOT
Using CachedRowSet
unable to compile
Servlet package and Tomcat Question