I’ve just started working on servlets and i’m a newbie. I have developed a html page with a submit button which invokes the servlet.Here is the html code for it.
<html>
<head>
<title>A simple revision of servlets</title>
</head>
<body>
<form method="POST" action="Idiot">
<input type="SUBMIT">
</form>
</body>
</html>
The deployment descriptor is as follows named as web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>TangoCharlie</servlet-name>
<servlet-class>com.example.web.Revise</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TangoCharlie</servlet-name>
<url-pattern>/Idiot</url-pattern>
</servlet-mapping>
</web-app>
The code for servlet is as follows which is named as :Revise.java
package com.example.web;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Revise extends HttpServlet
{
public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
{
response.setContentType("text/html");
PrintWriter out=response.getWriter();
//out.println("<html><body><h3>Hello</h3></body></html>");
out.println("Hello");
}
}
I have maintained the following directories inside webapps of tomcat server.
webapps->Revision->page.html
webapps->Revision->WEB-INF->web.xml
webapps->Revision->WEB-INF->classes->com->example->web->Revise.class
When i run page.html in Mozilla Firefox and click on submit,i get a blank page.
When i run page.html in Chrome ,i get the following message:
Server error
The website encountered an error while retrieving http://localhost:8080/Revision/Idiot.It may be down for maintenance or configured incorrectly.
Here are some suggestions:
Reload this webpage later.
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
Where am i wrong ???
As suggested by @Metalhead i just needed to restart tomcat.
The typo “Revisio” is my mistake during copying and pasting as the page on chrome spreaded out towrds right side and i missed that character ‘n’ in ‘Revision’.I strongly apologise for that.