Hi all,
I have created a simple servlet with one one JSP.
The files are,
index.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login Page</title>
<link rel="stylesheet" type="text/css" href="css/style1.css" />
</head>
<body>
<div style="background: LightBlue ">
<h1 align="center">Sample Application</h1>
</div>
<FORM action="/myServlet" method="GET">
What's your name?
<INPUT TYPE=TEXT NAME="name"><P>
<INPUT TYPE=SUBMIT>
</FORM>
</body>
</html>
web.xml
<?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>myServlet</servlet-name>
<servlet-class>classes.servlet.myServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myServlet</servlet-name>
<url-pattern>/myServlet</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
</web-app>
myServlet.java
package classes.servlet;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class myServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
String name = req.getParameter("name");
out.println(name);
out.println("<HTML>");
out.println("<HEAD><TITLE>Hello, " + name + "</TITLE></HEAD>" );
out.println("<BODY>");
out.println("Hello, " + name);
out.println("</BODY></HTML>");
}
}
When im trying to give name & press Submit, error is coming as,
HTTP Status 404 - /myServlet
type : Status report
message : /myServlet
description : The requested resource (/myServlet) is not available.
Apache Tomcat/5.5.17
Im using NetBeans, My folder Structure is,
C:\Documents and Settings\mani\test\web\index.jsp
C:\Documents and Settings\mani\test\web\WEB-INF\web.xml
C:\Documents and Settings\mani\test\src\java\classes\servlet\myServlet.java
Please help me in this regard.....