Greetings everyone!
I'm a newbie with Tomcat and i've already been trying out a simple server 
example for about 2 days now and still it wouldnt work. I really hope 
someone would help me out. 

Specifications:
1. operating system : windows xp sp2
2. java : jdk 1.5
3. tomcat : version 5.5
*i'm using ant for compiling and building

Here is the code for the servlet i'm trying to run:

package chapter2;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class SimpleServlet extends HttpServlet {
public void init(ServletConfig config)
throws ServletException {
// Always pass the ServletConfig object to the super class
super.init(config);
}
//Process the HTTP Get request
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Simple Servlet</title></head>");
out.println("<body>");
// Outputs the address of the calling client
out.println("Your address is " + request.getRemoteAddr()
+ "\n");
out.println("</body></html>");
out.close();
}
}

Yes, this is an example from the book "Mastering Jakarta Struts". The tomcat 
version used in the book is really a lot older, so i had to read the 
documentation of version 5.5 and did everything written there. I structured 
the directory hierarchy correctly and even exercised the proper source code 
management.

Here is my web.xml code:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app 
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
"http://java.sun.com/dtd/web-app_2_3.dtd";<http://java.sun.com/dtd/web-app_2_3.dtd%22>
>

<web-app>


<!-- General description of your web application -->

<display-name>wileyapp</display-name>
<description>
This is my first ever servlet and i hope it will
finally work. Please Lord, make it work...
</description>

<context-param>
<param-name>webmaster</param-name>
<param-value>[EMAIL PROTECTED]</param-value>
<description>
The EMAIL address of the administrator to whom questions
and comments about this application should be addressed.
</description>
</context-param>

<servlet>
<servlet-name>SimpleServlet</servlet-name>
<description>
This servlet plays the "controller" role in the MVC architecture
used in this application. It is generally mapped to the ".do"
filename extension with a servlet-mapping element, and all form
submits in the app will be submitted to a request URI like
"saveCustomer.do", which will therefore be mapped to this servlet.

The initialization parameter namess for this servlet are the
"servlet path" that will be received by this servlet (after the
filename extension is removed). The corresponding value is the
name of the action class that will be used to process this request.
</description>
<servlet-class>chapter2.SimpleServlet</servlet-class>
<!-- Load this servlet at server startup time -->
<load-on-startup>5</load-on-startup>
</servlet>

<session-config>
<session-timeout>30</session-timeout> <!-- 30 minutes -->
</session-config>

</web-app>

To my desperation I even added a context path to the server.xml which was 
practiced for older versions of tomcat. I also checked whether the web 
application was deployed and the tomcat manager indicated that, yes, it was 
already deployed. But i can't seem to make the servlet work. I kept 
accessing it at http:/localhost:8080/wileyapp/servlet/chapter2.SimpleServlet 
but it just doesnt work. I even tried the other tutorials available online 
but these also didnt work. what seems to be the problem here? Im actually 
considering using an older version of tomcat because there are more 
tutorials and pointers for using them.

Reply via email to