tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ben short" <...@benshort.co.uk>
Subject Re: Servlet Mappings
Date Mon, 30 Oct 2006 19:49:35 GMT
Heres the web.xml mapping to a simple servlet..

<web-app>
  <display-name>Archetype Created Web Application</display-name>
    <servlet>
        <servlet-name>test</servlet-name>
        <servlet-class>Test</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
   <servlet-mapping>
       <servlet-name>default</servlet-name>
       <url-pattern>/images/*</url-pattern>
   </servlet-mapping>
    <servlet-mapping>
       <servlet-name>test</servlet-name>
       <url-pattern>/</url-pattern>
   </servlet-mapping>
</web-app>

The Servlet

public class Test extends HttpServlet
    {
    protected void doGet(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) throws ServletException,
IOException
        {
        httpServletResponse.getWriter().write("<html>\n" +
                "  <head><title>Simple jsp page</title></head>\n"
+
                "  <body><img src=\"images/test.jpg\" alt=\"\" /></body>\n"
+
                "</html>");
        httpServletResponse.getWriter().flush();
        }
    }

The webapp was deploed to http://myhost/test via the tomcat manger
webapp. On going to the http://myhost/test url the webpage is shown
but no image. Going to http://myhost/test/images/test.jpg give a 404.

Ben


On 10/30/06, ben short <ben@benshort.co.uk> wrote:
> I deploy this test webapp via the tomcat manager to http://myhost/test.
>
> The appBase in the sever.xml is set, as default, to webapps. The
> directory structure is
>
> webapps
>   - ROOT - Currently another applicaiton I have setup.
>  - test - The test application.
>
> When deploying to the root, just name the war file ROOT.xml the rest
> of the server is configured as default.
>
> To url to trigger the jsp is http://myhost/test/test.html.
>
> Im just knocking up a servlet to do the same thing to remove spring
> from the picture.
>
> Ben
>
>
> On 10/30/06, Caldarale, Charles R <Chuck.Caldarale@unisys.com> wrote:
> > > From: jamin.short@gmail.com [mailto:jamin.short@gmail.com]
> > > Subject: Re: Servlet Mappings
> > >
> > > Im deploying a war file. Im also using spring. I havent touched the
> > > web.xml. I have litrally downloaded and un tared the file from the
> > > apache tomcat website.
> >
> > I'm not familiar with configuring spring, so someone else will have to
> > check that.  I suspect it's muddying up the picture.
> >
> > > Here is the layout of the test app;lication i have setup to
> > > try it out.
> >
> > That looks o.k. as far as it goes, but you didn't tell us where it's
> > actually deployed, nor how you think you got it to be ROOT.  Do you have
> > a conf/[engine]/[host]/ROOT.xml with a <Context> element and a docBase
> > attribute pointing to wherever your .war is?  If the .war is also in the
> > <Host>'s appBase directory, you've deployed the app twice, which is
> > probably not desirable.
> >
> > So again, what is your appBase set to?  What's the directory structure
> > underneath the appBase?
> >
> > What URL do you use to trigger execution of the test.jsp file?  Can you
> > try this without using spring?
> >
> >  - 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
> >
> >
>

---------------------------------------------------------------------
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