Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

I dont know how to map my servlets properly (Tomcat)

843841Oct 2 2007 — edited Oct 9 2007
Hello I've got a problem with web.xml settings on my Tomcat.

i have a servlet:

package pack;

*public class Foo extends HttpServlet{*
*public void doGet(){*
*....*
response.sendRedirect("/AnotherServlet");
*....*
*}*
*}*
this servlet is in the directory:
tomcat5.5\webapps\MyWebApp\WEB-INF\classes\pack\Foo.class

my web.xml file looks like that:
*<?xml version="1.0" encoding="ISO-8859-2"?>*

*<!DOCTYPE web-app*
* PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"*
* "http://java.sun.com/dtd/web-app_2_3.dtd">*
*<web-app>*

* <servlet>*
* <servlet-name>Foo</servlet-name>*
* <servlet-class>pack.Foo</servlet-class>*
* </servlet>*
* <servlet-mapping>*
* <servlet-name>Foo</servlet-name>*
* <url-pattern>/Foo</url-pattern>*
* </servlet-mapping>*

* <servlet>*
* <servlet-name>AnotherServlet</servlet-name>*
* <servlet-class>pack.**AnotherServlet*
*</servlet-class>*
* </servlet>*
* <servlet-mapping>*
* <servlet-name>**AnotherServlet*
*</servlet-name>*
* <url-pattern>**/AnotherServlet*
*</url-pattern>*
* </servlet-mapping>*
*</webapp>*

and my question is why the Foo servlet
http://localhost:port/MyWebApp/Foo
redirects to
http://localhost:port/AnotherServlet
and not to
http://localhost:port/MyWebApp/AnotherServlet

Thanks a lot for solving this I-think-little problem.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 6 2007
Added on Oct 2 2007
2 comments
87 views