I had the same servlet-mapping problems and the right ApJServMount command
is:

ApJServMount /<context_path>/myServlet /<context_path>/myServlet

( You must omit the 'servlet' string from the mount command ! )

In that way Apache knows to redirect /myServlet URL to Tomcat.

You can make it more straight foreword and redirect every thing under
<context_path>
to Tomcat by:

ApJServMount /<context_path> /<context_path>

But then also static files ( like HTMLs and GIFs ) will be directed as well
to Tomcat ( which usually you don't want )

You are right, and I don't have the answer for this, that in order to
redirect only servlets from Apache to Tomcat we need to write specifically
the servlets url-pattern in a special ApJServMount command, which actually
duplicates the information in the web.xml file. 

Very bad!!. Does any body have the answer for it?

I have some thoughts that the using Jk_mod maybe more flexible, but didn't
yet check it.

Eitan Ben-Noach



> -----Original Message-----
> From: Colin Hawkett [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 04, 2001 9:19 AM
> To: [EMAIL PROTECTED]
> Subject: Apache - Tomcat - Servlet Mapping
> 
> 
> Hi all,
> 
>     This question seems to be popping up pretty regularly, 
> but I couldn't
> extract a solution to my problem - namely: getting apache to recognise
> servlet-mappings. I am running tomcat 3.2.2 and apache 1.3.11 
> on win98.
> 
> I have a web application packaged up as a war file and deployed to the
> webapps directory.  The web.xml file contains (among other things)
> 
> <servlet>
>     <servlet-name>theServlet</servlet-name>
>     <servlet-class>com.myco.test.TheServlet</servlet-class>
> </servlet>
> 
> <servlet-mapping>
>     <servlet-name>theServlet</servlet-name>
>     <url-pattern>/myServlet</url-pattern>
> </servlet-mapping>
> 
> Now, I've confirmed that the mapping is correct by accessing 
> it using the
> URL
> 
> http://myserver:8080/<context_path>/myServlet    - This is 
> fine, no problems
> 
> As I understand it, this is connecting to the tomcat web 
> server (on port
> 8080), which is aware of the servlet mapping because it has 
> read the web.xml
> file for application.  And this is how I would expect it to 
> work.  Cool.
> 
> However, I don't want Tomcat to be my web server.  I want 
> apache to be my
> webserver.  So I try to access the application using the URL
> 
> http://myserver/<context_path>/myServlet    -  This fails!
> 
> everything about the web-app works with apache except the 
> servlet mapping,
> so I assume Apache is unaware of it.  The closest thing to a 
> solution I have
> found is that I need to add a line to 'tomcat-apache.conf' that looks
> something like -
> 
> ApJServMount    /<context_path>/myServlet
> /<context_path>/servlet/theServlet
> 
> which seems like a really annoying thing to have to do.  The 
> whole point of
> web-apps is that you define everything you need to in 
> web.xml, so that you
> don't have to change configuration files on the deployment 
> system.  If this
> is necessary, then what is the point of the servlet-mapping?  
> Surely tomcat
> should generate the necessary ApJServMount lines in
> "tomcat-apache.conf" when it starts up and reads web.xml?
> 
> So, the big question is -
> 
> * Is it possible to get apache to recognise servlet mappings 
> defined in a
> web-app's web.xml without explicitly making a modification to 
> an apache
> config file? If so, how?
> 
> * If not can someone give a concrete example of a servlet 
> mapping, and the
> corresponding ApJServMount line that will get apache to recognise that
> mapping?
> 
> I hope this all makes sense - appreciation in advance,
> 
> Colin
> 
> 

Reply via email to