Biggie_mac
OSNN Junior Addict
- Joined
- 16 Feb 2005
- Messages
- 18
I have a very simple servlet to run....and it doesn't work..I dwl Tomcat 5.0.28, installed it to C:\Tomcat 5....started the procces, typed localhost:8080 in the browser...everything worked out. I even tried some of thei examples and they worked. Now I want to run this very simple servlet:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SimpleCounter extends HttpServlet {
int count = 0;
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/plain");
PrintWriter out = res.getWriter();
count++;
out.println("Since loading, this servlet has been accessed " +
count + " times.");
}
}
I saved the file as SimpleCounter.java, copy it to ROOT/Web-inf/classes/ and typed localhost:8080/servlet/SimpleCounter.
As I read on tutorials and books this is the simplest way to run a servlet. But it doesn't work for me!! I get this message:
HTTP Status 404 - /servlet/SimpleCounter
type Status report
message /servlet/SimpleCounter
description The requested resource (/servlet/SimpleCounter) is not available.
Apache Tomcat/5.0.28
What am I doing wrong? I'm new with servlets so ....
10x very much!!
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SimpleCounter extends HttpServlet {
int count = 0;
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/plain");
PrintWriter out = res.getWriter();
count++;
out.println("Since loading, this servlet has been accessed " +
count + " times.");
}
}
I saved the file as SimpleCounter.java, copy it to ROOT/Web-inf/classes/ and typed localhost:8080/servlet/SimpleCounter.
As I read on tutorials and books this is the simplest way to run a servlet. But it doesn't work for me!! I get this message:
HTTP Status 404 - /servlet/SimpleCounter
type Status report
message /servlet/SimpleCounter
description The requested resource (/servlet/SimpleCounter) is not available.
Apache Tomcat/5.0.28
What am I doing wrong? I'm new with servlets so ....
10x very much!!