tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Schröder ...@deriva.de>
Subject How can I control the path of my web app?
Date Mon, 23 Apr 2007 19:07:39 GMT
Hi list!
It seems that I have not yet understood the concept of webapps, 
contexts, servlet mappings etc. I have a long experience with good old 
Apache web server, but I'm quite new to servlet development / deployment 
in general and Tomcat in particular.
My problem is as follows: I have a Tomcat 5.5 server with the 
out-of-the-box configuration. And I have a webapp which is packed in a 
war file, say "MyWebApp.war". This file contains some classes (servlets) 
in the "WEB-INF/classes" directory, a "web.xml" file in "WEB-INF" and a 
"context.xml" in "META-INF". I have write access to the "webapps" 
directory of the server (but only to this directory), so I can place the 
war file there. Tomcat (having "autoDeploy" enabled) then creates a 
directory "MyWebApp" in the "webapps" directory and extracts everything 
from the war file to this directory. After this has been done, I can 
find my servlets at the url "http://127.0.0.1:8080/MyWebApp/..."
Ok, this works fine. But now I want my servlets to be accessible at 
"http://127.0.0.1:8080/foo/bar/MyWebApp/...". How can I achieve this? I 
have tried to create the directory structure in the "webapps" directory 
and put the war file into "webapps/foo/bar", but then Tomcat doesn't 
unpack the war file at all. Simply changing the "path" attribute of the 
"Context" element in my "context.xml" file didn't work, too.
Is this possible at all if I only have access to the "webapps" directory 
(and not, for example, to the manager application)?

Thanks a lot for your help,
    Christian

My context.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/MyWebApp"/>

My web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <servlet>
        <servlet-name>TestServlet</servlet-name>
        <servlet-class>TestServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>TestServlet</servlet-name>
        <url-pattern>/TestServlet</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>TestServlet</welcome-file>
    </welcome-file-list>
</web-app>

-- 
Deriva GmbH                         Tel.: +49 551 489500-42
Financial IT and Consulting         Fax:  +49 551 489500-91
Hans-Böckler-Straße 2                  http://www.deriva.de
D-37079 Göttingen

Deriva CA Certificate: http://www.deriva.de/deriva-ca.cer


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message