• 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

path for forward()'ing to another servlet?

 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use the mapping associated to ServletB (in web.xml), not the full qualified path to the class file.
 
sven studde
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I got it to work.
 
I love a woman who dresses in stainless steel ... and carries tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic