And
And

Reputation: 343

Tomcat 6 doesn't see servlet mapped in web.xml

I'm trying to access servlet typing

http://localhost:8082/Libruary/controller

and Tomcat 6 gives an error 404:

HTTP Status 404 - /Libruary/controller

type Status report

message /Libruary/controller

description The requested resource (/Libruary/controller) is not available.
Apache Tomcat/6.0.26

Which means that something is wrong in web.xml file, I suppose.

So, here is my web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
  version="2.4" 
  xmlns="http://java.sun.com/xml/ns/j2ee" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
  http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<servlet>
    <servlet-name>Controller</servlet-name>
    <servlet-class>by.epam.web.libruary.jspservlet.Controller</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Controller</servlet-name>
    <url-pattern>/controller</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>

I named and mapped the servlet, that's why I don't know what's incorrect. And here is project hierarchy in tomcat folder:

webapps
--Libruary
---web.xml
---...
---WEB-INF
----classes
-----by
------epam
-------web
--------libruary
---------jspservlet
----------Controller.class

I generated .class file using Eclipse. And .java files are in /scr directory, which is on the same level with classes (but it's optional, I suppose). Also I have /lib directory in this level, which contains servlet-api.jar. I don't know what to say else. Will be very grateful for your help.

Upvotes: 3

Views: 2188

Answers (1)

Piotr Nowicki
Piotr Nowicki

Reputation: 18174

web.xml should be inside WEB-INF/.

Upvotes: 4

Related Questions