You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Terence Kent <tk...@xetus.com> on 2008/02/03 19:19:17 UTC
servlet mapping question(I believe)
Hello all,
I am new to tomcat and running into a problem that I am unable to
resolve. I don't know all the correct vocabulary to use here, so bare
with me as I attempt to describe the problem I'm running into. Here
goes...
In a nutshell:
All requests to:
dwww.mycompany.com:8010/foor/bar.ext
get forwarded correctly to the servlet running in ${APP_BASE} until a
directory named ${APP_BASE}/foo exists. Once a directory named $
{APP_BASE}/foo exists (and can be empty), no requests of the form
above will get sent to the correct (in this case only) servlet. I
simply get a 404 error as a response.
The details:
I believe this issue has to do with how tomcat maps a request to a
servlet, but have no idea of what I'm doing wrong. My research online
of sun's servlet spec and the tomcat website hasn't provided me a
solution (or has and I haven't recognized it :-P). Here is my
server.xml configuration:
<Server port="8005" shutdown="SHUTDOWN">
<Service name="Tomcat-Page">
<Connector port="8010" enableLookups="false"/>
<Engine name="Page" defaultHost="dwww.mycompany.com">
<Host name="dwww.mycompany.com" appBase="/opt/path/to/webapps/page"
unpackWARs="false" autoDeploy="true">
<Context path=""
docBase="."
reloadable="true"
crossContext="true"
cookies="false" >
</Context>
</Host>
</Engine>
</Service>
</Server>
And the web.xml configuration in /opt/path/to/webapps/page/WEB-INF/:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<display-name>Page Application</display-name>
<servlet>
<servlet-name>mycompany</servlet-name>
<servlet-class>
mycompany.PageProcessor
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mycompany</servlet-name>
<url-pattern>*.ext</url-pattern>
</servlet-mapping>
</web-app>
Conclusion:
My understanding from this configuration is that all requests on port
8010, that end with the extension .ext should be forwarded to the
servlet "mycompany". From what I've read, any paths created in the $
{APP_BASE} directory should be irrelevant in this mapping and all
logic comes from the web.xml file. My understanding appears to be
wrong and I would greatly appreciate being pointed in the right
direction.
Side Note:
This issue does not occur when hosted on windows for some reason, just
when on linux and Mac OS X.
Thank you in advance!
Terence.
RE: servlet mapping question(I believe)
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Terence Kent [mailto:tkent@xetus.com]
> Subject: Re: servlet mapping question(I believe)
>
> In my case I have multiple applications in the webapps
> folder, so which to name to root is ambiguous.
The one to name ROOT (not root) is the one you want clients to see when
they specify only the host name on the URL - it's the default webapp for
the web site.
> Is it acceptable to have multiple applications in a
> webapps folder, with base directories such as:
>
> webapps/app1
> webapps/app2
> ...
>
> All sharing the same appBase, but each having a different docBase?
That is the normal way of doing things. Note that the docBase attribute
must not be specified in any <Context> elements in this scenario, since
it's derived from the location of the webapp.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.
---------------------------------------------------------------------
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
Re: servlet mapping question(I believe)
Posted by Terence Kent <tk...@xetus.com>.
On Feb 3, 2008, at 10:58 AM, Konstantin Kolinko wrote:
Konstanin,
Thank you for your response! Below are responses to your statements...
>> "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
>
> Why are you using such an old version of specification? Why not 2.4
> or 2.5??
I think my question was malformed. I read the 2.4 specification from
sun, I have no idea which I'm actually using.
>
>
> Nowadays, with tomcat 5.5 and 6.0 it is very rare (and discouraged) to
> configure context in server.xml.
This makes sense, I'll change this configuration.
>
>
> For the root application it is sufficient to name it "ROOT" (in upper
> case) and place it into webapps folder.
In my case I have multiple applications in the webapps folder, so
which to name to root is ambiguous. Is it acceptable to have multiple
applications in a webapps folder, with base directories such as:
webapps/app1
webapps/app2
...
All sharing the same appBase, but each having a different docBase?
Thanks again for your response.
Terence.
>
>
> ---------------------------------------------------------------------
> 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
>
---
Terence Kent
Support and Training Management
Xetus Corporation
Re: servlet mapping question(I believe)
Posted by Konstantin Kolinko <kn...@gmail.com>.
> "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
Why are you using such an old version of specification? Why not 2.4 or 2.5??
Nowadays, with tomcat 5.5 and 6.0 it is very rare (and discouraged) to
configure context in server.xml.
For the root application it is sufficient to name it "ROOT" (in upper
case) and place it into webapps folder.
---------------------------------------------------------------------
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
Re: servlet mapping question(I believe)
Posted by Terence Kent <tk...@xetus.com>.
Mark,
Thank you very much! Your suggestion worked perfectly and has given me
an area to focus on.
Terence.
On Feb 3, 2008, at 10:51 AM, Mark Thomas wrote:
> Terence Kent wrote:
>> Conclusion:
>> My understanding from this configuration is that all requests on
>> port 8010, that end with the extension .ext should be forwarded to
>> the servlet "mycompany". From what I've read, any paths created in
>> the ${APP_BASE} directory should be irrelevant in this mapping and
>> all logic comes from the web.xml file. My understanding appears to
>> be wrong and I would greatly appreciate being pointed in the right
>> direction.
>
> You can't set appBase == docBase.
>
> The following should do what you want:
> rename /opt/path/to/webapps/page to /opt/path/to/webapps/ROOT
> use appBase="/opt/path/to/webapps"
> use docBase="ROOT"
>
> Also, I wouldn't configure the context in server.xml. See http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
> for other options.
>
> HTH,
>
> Mark
>
>
> ---------------------------------------------------------------------
> 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
>
---
Terence Kent
Support and Training Management
Xetus Corporation
Re: servlet mapping question(I believe)
Posted by Mark Thomas <ma...@apache.org>.
Terence Kent wrote:
> Conclusion:
> My understanding from this configuration is that all requests on port
> 8010, that end with the extension .ext should be forwarded to the
> servlet "mycompany". From what I've read, any paths created in the
> ${APP_BASE} directory should be irrelevant in this mapping and all logic
> comes from the web.xml file. My understanding appears to be wrong and I
> would greatly appreciate being pointed in the right direction.
You can't set appBase == docBase.
The following should do what you want:
rename /opt/path/to/webapps/page to /opt/path/to/webapps/ROOT
use appBase="/opt/path/to/webapps"
use docBase="ROOT"
Also, I wouldn't configure the context in server.xml. See
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html for other options.
HTH,
Mark
---------------------------------------------------------------------
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