Galli
Galli

Reputation: 23

Tomcat and request mapping

I have got stuck with a simple webapp.

After other complexer examples are failed to run, trying to test a sample app that i found here: http://www.mkyong.com/spring3/spring-3-mvc-hello-world-example/

I am trying to run it under Tomcat, therefore i have only changed

<servlet-mapping>
        <servlet-name>mvc-dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
</servlet-mapping>

to

<servlet-mapping>
        <servlet-name>mvc-dispatcher</servlet-name>
        <url-pattern>/samplejsp/*</url-pattern>
</servlet-mapping>

After deploying to Tomcat i have tried to get the welcome page on the web browser, but all i see is: "HTTP Status 404" for "http://localhost:8080/samplejsp/", "http://localhost:8080/samplejsp/welcome", "http://localhost:8080/welcome/".

Trying to debug the servlet with Eclipse have not helped, eclipse connects to tomcat, but nothing happens and the breakpoint remains untouched at requesting the mentioned urls.

Tomcat shows the app as deployed and running.

I suppose i do not get something about request mapping but i have no more ideas. Thanks for help and sorry for referring an external page.

Upvotes: 0

Views: 2003

Answers (2)

Ramesh PVK
Ramesh PVK

Reputation: 15456

The <url-pattern> in servlet mapping should not contain the application context root.

Change <url-pattern>/samplejsp/*</url-pattern> to <url-pattern>/*</url-pattern>

Upvotes: 0

nfechner
nfechner

Reputation: 17545

The <url-pattern> is relative to the web-app, not the Tomcat server.

If you specifiy something like <url-pattern>/samplejsp/*</url-pattern> and your application is installed at /samplejsp the servlet will reside at: http://localhost:8080/samplejsp/samplejsp/

Fore more information see the Oracle documentation for web.xml Deployment Descriptor Elements.

Upvotes: 0

Related Questions