HTTP Status 404 - Servlet .... is not available

I use eclise to create a servlet like this :

package hello;
public class NewServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    String name = request.getParameter("textField");

    PrintWriter pw = response.getWriter();
    pw.print("Hello " + name + "!");

and a html file like :

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<form method="post" action="NewServlet">
    <p align="center">
        <font>Input some text</font> <br> <input type="text"
            name="textFiled"> <br> <input type="submit"
            value="submit"> <br>

when i run the servlet, met an error :

HTTP Status 404 - Servlet NewServlet is not available


type Status report

message Servlet NewServlet is not available

description The requested resource (Servlet NewServlet is not available) is not available.

i checked the folder : WEB-INF or any folder else and can't see file .class

How is this caused and how can I solve it?


You should check web-inf folder in your IDE and map your servlet in web.xml file


make sure that this mapping is done properly and also your servlet is not in any package or folder if so then in servlet tag write that class name followed by . and your servlet name.

If problem still arises just make sure that you delete that .class file of your servlet and build your project again.(Net beans have an option of clean and build and then run) haven't use eclipse but i am sure it has similar option as well

Servlets needs to be registered and mapped on a specific URL pattern in order to be able to execute them by a HTTP request. Given your HTML code you seem to expect the servlet to listen on an URL of /NewServlet.

If you're using Tomcat 7, then just put the @WebServlet annotation on the class with exactly that URL pattern:

public class NewServlet extends HttpServlet {
    // ...

If you're still on Tomcat 6 or older for some reason, then you'd need to do it by the old fashioned web.xml way. A concrete example can be found in our servlets wiki page.

Eclipse won't show .class files in the project explorer. It will only show them in the navigator, in the /build folder. But this should not be something to worry about right now.

Format in web.xml should be like this.


which in your case is


edite this: form method="post" action="NewServlet"

to this form method="post" action="/(your project name ) /NewServlet"

i had the same problem and this worked for me

Need Your Help

Kendo DatePicker culture not working correctly razor kendo-ui culture

I want to localize Kendo Datepicker to my culture "is-IS" but for some reason it doesn´t work correctly. This is code example:

Highlight the parent even when a child element is selected (opencart)

javascript parent-child drop-down-menu opencart

Last week I created an e-shop with opencart. Now I'm trying to customize the default top menu. What I want to do is to keep the parent highlighted even when a child element is selected