T
Thomas Hoheneder
Hello,
I have a problem with getting a Java Servlet work within Tomcat 5.0.28. I
have compiled a class TestingServlet.class with JDK 1.3.1 which is
recommended for use with Tomcat 5.0. Let me tell you, that this is just my
first servlet at all. For the work I use a book with the title "Java for the
Web with Servlets, JSP and EJB" from Budi Kurniawan. My TestingServlet's
code is exactly the following, where the compiling went right:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class TestingServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>Servlet Testing</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("Welcome to the Servlet Testing Center");
out.println("</BODY>");
out.println("</HTML>");
}
}
As operating system I use Windows XP SP1 and my JAVA_HOME points to
"C:\jdk131" which I have also configured for Tomcat. Now, the book tells me
to put the TestingServlet.class file into a sub directory "myApps" of the
webapps directory, which is under my Tomcat installation path. Furthermore I
have a deployment descriptor named web.xml. So in a whole I have the
following files:
<TOMCAT-HOME>/webapps/myApp/WEB-INF/TestingServlet.java
<TOMCAT-HOME>/webapps/myApp/WEB-INF/web.xml
<TOMCAT-HOME>/webapps/myApp/classes/TestingServlet.class
My deployment descriptor (web.xml) looks like as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 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"
version="2.4">
<servlet>
<servlet-name>Testing</servlet-name>
<servlet-class>TestingServlet</servlet-class>
</servlet>
</web-app>
Then I start the Tomcat server via the Tomcat monitor. At the URL
http://localhost:8080 I can see a standard starting page of Tomcat. Now the
book tells me that I can use the following URL to see my TestingServlet's
output:
http://localhost:8080/myApp/servlet/Testing
But this doesn't work. Instead of seeing the text "Welcome to the Servlet
Testing Center" I get the following error message in the browser window (I
use IE 6.0):
HTTP Status 404 - /myApp/servlet/Testing
------------------------------------------------------------------------
type Status report
message /myApp/servlet/Testing
description The requested resource (/myApp/servlet/Testing) is not
available.
----------------------------------------------------------------------------
Apache Tomcat/5.0.28
I have even tried the following URL's, but none of them lead to the result I
have expected:
http://localhost:8080/myApp/Testing
http://localhost:8080/servlet/Testing
http://localhost:8080/Testing
http://localhost:8080/myApp/servlet/TestingServlet
http://localhost:8080/myApp/TestingServlet
http://localhost:8080/servlet/TestingServlet
http://localhost:8080/TestingServlet
I always get the error above.
My question is: What went wrong? Why do I not get the text "Welcome to the
Servlet Testing Center" of my TestingServlet displayed in the browser
window?
Any help to this would be very appreciated. Thanks in advance.
Nice greetings from
Thomas
I have a problem with getting a Java Servlet work within Tomcat 5.0.28. I
have compiled a class TestingServlet.class with JDK 1.3.1 which is
recommended for use with Tomcat 5.0. Let me tell you, that this is just my
first servlet at all. For the work I use a book with the title "Java for the
Web with Servlets, JSP and EJB" from Budi Kurniawan. My TestingServlet's
code is exactly the following, where the compiling went right:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class TestingServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>Servlet Testing</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("Welcome to the Servlet Testing Center");
out.println("</BODY>");
out.println("</HTML>");
}
}
As operating system I use Windows XP SP1 and my JAVA_HOME points to
"C:\jdk131" which I have also configured for Tomcat. Now, the book tells me
to put the TestingServlet.class file into a sub directory "myApps" of the
webapps directory, which is under my Tomcat installation path. Furthermore I
have a deployment descriptor named web.xml. So in a whole I have the
following files:
<TOMCAT-HOME>/webapps/myApp/WEB-INF/TestingServlet.java
<TOMCAT-HOME>/webapps/myApp/WEB-INF/web.xml
<TOMCAT-HOME>/webapps/myApp/classes/TestingServlet.class
My deployment descriptor (web.xml) looks like as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 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"
version="2.4">
<servlet>
<servlet-name>Testing</servlet-name>
<servlet-class>TestingServlet</servlet-class>
</servlet>
</web-app>
Then I start the Tomcat server via the Tomcat monitor. At the URL
http://localhost:8080 I can see a standard starting page of Tomcat. Now the
book tells me that I can use the following URL to see my TestingServlet's
output:
http://localhost:8080/myApp/servlet/Testing
But this doesn't work. Instead of seeing the text "Welcome to the Servlet
Testing Center" I get the following error message in the browser window (I
use IE 6.0):
HTTP Status 404 - /myApp/servlet/Testing
------------------------------------------------------------------------
type Status report
message /myApp/servlet/Testing
description The requested resource (/myApp/servlet/Testing) is not
available.
----------------------------------------------------------------------------
Apache Tomcat/5.0.28
I have even tried the following URL's, but none of them lead to the result I
have expected:
http://localhost:8080/myApp/Testing
http://localhost:8080/servlet/Testing
http://localhost:8080/Testing
http://localhost:8080/myApp/servlet/TestingServlet
http://localhost:8080/myApp/TestingServlet
http://localhost:8080/servlet/TestingServlet
http://localhost:8080/TestingServlet
I always get the error above.
My question is: What went wrong? Why do I not get the text "Welcome to the
Servlet Testing Center" of my TestingServlet displayed in the browser
window?
Any help to this would be very appreciated. Thanks in advance.
Nice greetings from
Thomas