1

I'm trying to run this code using tomcat in eclipse

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="serv">
<input type="submit">
</form>
</body>
</html>

When I click on submit button, the following error message appears

HTTP Status 404 - /Ajax/serv

type Status report

message /Ajax/serv

description The requested resource (/Ajax/serv) is not available.

I was working on a JSP project without any problems, until I removed the JSP and Servers projects and created new ones. Since then, it's not working.

Any suggestions please?

Islam Hassan
  • 1,736
  • 4
  • 26
  • 42

2 Answers2

1

Make sure that your servlet class is inside a package and has the @WebServlet annotation with an URL pattern of at least /serv.

package com.example;

// ...

@WebServlet("/serv")
public class YourServletClassName extends HttpServlet {

    // ...

}

The URL pattern can also be /serv/* depending on whether you'd like to support path info or not.

If your servlet class already has one, then something failed during servlet's construction or initialization. Detailed information about that should be available in the server's logs which you can find in Eclipse's console.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks very much. The annotation already exists but I've created serv in the default package. Now working after moving it inside a package. – Islam Hassan Apr 24 '12 at 05:06
0

Check whether the jsp file is present inside WEB-INF folder, if so please move it under web content.This will solve your issue

Raphael
  • 1,738
  • 2
  • 27
  • 47