Hi,
I have a simple webapp with 1servler. When I run my webapp in Tomcat5
and try accessing my servlet using
http://localhost:8080/HelloServlet/HelloServlet , I get a 404 error
page stating --
HTTP Status 404 - /HelloServlet/HelloServlet
type Status report
message /HelloServlet/HelloServlet
description The requested resource (/HelloServlet/HelloServlet) is not
available.
Apache Tomcat/5.0.19
-----
The following is the servlet code:---
import javax.servlet.http.*;
import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
public class HelloServlet extends HttpServlet
{ private ServletConfig config;
public void init(ServletConfig config) throws ServletException
{this.config=config;}
public void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException,IOException
{}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{doPost(req,res);}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
ServletContext context=getServletContext();
String name=context.getInitParameter("name");
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("<html><body>Hello World");
out.println("context parameter name: "+ name);
out.println("</body></html>");
out.close();
}
}
------------
The following is the web.xml---------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<context-param>
<param-name>name</param-name>
<param-value>pi</param-value>
</context-param>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>HelloServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/HelloServlet/</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>270</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
</web-app>
--------
I am able to access index.jsp by using http://localhost:8080/HelloServlet/
What do I need to do to be able to access the servlet class? Do I need
to do some special kind of configuration in Tomcat?
Thanks in advance for the help.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]