I'm desperately trying to execute a Servlet from an HTML action form and getting the following error message:
HTTP Status 404 - /WSE_Web/QueryServlet
type: Status report
message: /WSE_Web/QueryServlet
description: The requested resource (/WSE_Web/QueryServlet) is not available.
I looked through several questions here and tutorials but I cannot find what I'm missing (also I'm not very familiar with Servlets and Web Programming).
I'm using Eclipse with Tomcat 7.0.12.
My Action form:
My Servlet class:
package servlet;
import java.io.*;
import javax.servlet.*;
import javax.servlet.annotation.*;
import javax.servlet.http.*;
@WebServlet("/QueryServlet")
public class QueryServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("Hello World");
}
}
My web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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" id="WebApp_ID" metadata-complete="true" version="3.0">
<display-name>WSE_Web</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
Project Structure:
/QueryServlet
with a slash. – RealSkepticweb.xml
file. Is this correct?. AFAIK, You need to stick to 3.0 for tomcat to know and process your annotations – blurfus