You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Bauer, Scott" <sc...@agiliti.com> on 2000/11/22 22:48:35 UTC

sample/myapp help (tomcat + apache + servlet not working, at leas t not as I would expect it too)

Ok folks, I need some help or my frustration level is going to go through
the roof.

The system:
Mandrake 7.2, java 1.3, tomcat 3.1, Ant 1.2.



The problem:
Has anyone been able to build the sample app that is in the
doc/appdev/sample directory?  I can not get the servlet to run with apache.
If I try and access http://localhost/myapp/hello I get a page not found.
http://localhost:8080/myapp/hello works, as does
http://localhost/myapp/servlet/HelloServlet although the image does not show
up correctly because it's looking in /myapp/servlet/images not /myapp/images
which is understandable.  As far as I understand it you should be able to
map /hello to /servlet/HelloServlet.  Is this not correct?  I'm hoping
someone knows that one line that I have to put in tomcat-apache.conf to make
this work.



Here are some of the conf files:

conf/server.xml ( part of it anyways )
        <Context path="/myapp" docBase="webapps/myapp" debug="0"
reloadable="true" >
        </Context>


doc/appdev/sample/etc/web.xml (This is where I thought the magic would
happen, and the mapping would take place)

<!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>Hello, World Application</display-name>
    <description>
        This is a simple web application with a source code organization
        based on the recommendations of the Application Developer's Guide.
    </description>

    <servlet>
        <servlet-name>HelloServlet</servlet-name>
        <servlet-class>Hello</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>HelloServlet</servlet-name>
        <url-pattern>/hello</url-pattern>
    </servlet-mapping>

</web-app>


conf/tomcat-apache.conf ( This is what gets generated anyways )

LoadModule jserv_module libexec/mod_jserv.so
ApJServManual on
ApJServDefaultProtocol ajpv12
ApJServSecretKey DISABLED
ApJServMountCopy on
ApJServLogLevel notice

ApJServDefaultPort 8007

AddType test/jsp .jsp
AddHandler jserv-servlet .jsp
Alias /myapp /usr/local/jakarta-tomcat/webapps/myapp
<Directory "/usr/local/jakarta-tomcat/webapps/myapp">
    Options Indexes FollowSymLinks
</Directory>
ApJServMount /myapp/servlet /myapp
<Location /myapp/WEB-INF/ >
    AllowOverride None
    deny from all
</Location>

Alias /examples /usr/local/jakarta-tomcat/webapps/examples
<Directory "/usr/local/jakarta-tomcat/webapps/examples">
    Options Indexes FollowSymLinks
</Directory>
ApJServMount /examples/servlet /examples
<Location /examples/WEB-INF/ >
    AllowOverride None
    deny from all
</Location>

Alias /test /usr/local/jakarta-tomcat/webapps/test
<Directory "/usr/local/jakarta-tomcat/webapps/test">
    Options Indexes FollowSymLinks
</Directory>
ApJServMount /test/servlet /test
<Location /test/WEB-INF/ >
    AllowOverride None
    deny from all
</Location>

ApJServMount /servlet /ROOT


Thanks for your help.
sb

Re: sample/myapp help (tomcat + apache + servlet not working, at leas t not as I would expect it too)

Posted by Jim Rudnicki <jd...@pacbell.net>.
This is a fairly typical problem.  Tomcat is not at fault, to get started,
run it standalone and your problems will go away, the <servlet-mapping>'s
will start working, your hair will grow back, etc., etc.

Apache is the source of your problem.  It needs to be told that
localhost/myapp/hello
should be directed to the servlet engine.  When it sees
localhost/myapp/servlet/HelloServlet
it can use a simple servlet/* to forward.  But without the "servlet" it does
not know.

My first advice is to dump the mappings.  All they do is save you from
typing 8 character when authoring html pages.  This is what I do.

Second advice is to manually add an entry to the Apache config file for
_each and every_ mapping.  I gave up on this approach real quickly.

Jim

----- Original Message ----- >
> The problem:
> Has anyone been able to build the sample app that is in the
> doc/appdev/sample directory?  I can not get the servlet to run with
apache.
> If I try and access http://localhost/myapp/hello I get a page not found.
> http://localhost:8080/myapp/hello works, as does
> http://localhost/myapp/servlet/HelloServlet although the image does not
show
> up correctly because it's looking in /myapp/servlet/images not
/myapp/images
> which is understandable.  As far as I understand it you should be able to
> map /hello to /servlet/HelloServlet.  Is this not correct?  I'm hoping
> someone knows that one line that I have to put in tomcat-apache.conf to
make
> this work.

... etc ...