Servlet <url-pattern>: Trouble Mapping to a Directory that's Below My Application Directory

StackOverflow https://stackoverflow.com/questions/22151344

  •  19-10-2022
  •  | 
  •  

Question

I want to have a dedicated directory for jsp and servlet development, but I can't map my app's logical name resource correctly. I tested the app without the extra directory as follow:

C:\tomcat1\webapps\beer-v1

The app ran successfully. But if I map the application to(my desired location):

C:\tomcat1\webapps\dev\beer-v1

The application does not run. I get a 404 error, resource not found. The following is my web.xml file.

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"  
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">


<servlet>
    <servlet-name>Ch3 Beer</servlet-name>
    <servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>Ch3 Beer</servlet-name>
    <url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>

</web-app>

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top