Hello!
Now that I have Tomcat up and running, it's time that I starting doing some
real work. Following a simple example in the book I'm using it says that
servlets are installed in the subdirectory "webapps\WEB-INF\servlets". I
put my class there (under "examples" directory of Tomcat) and shut down
Tomcat and re-started it. Below is the code for textbook example:
// Fig. 19.5: HTTPGetServlet.java
// Creating and sending a page to the client
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class HTTPGetServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
PrintWriter output;
response.setContentType("text/html"); // content type
output = response.getWriter(); // get writer
// create and send HTML page to client
StringBuffer buf = new StringBuffer();
buf.append("<HTML><HEAD><TITLE>\n");
buf.append("A simple Servlet Example\n");
buf.append("</TITLE></HEAD><BODY>\n");
buf.append("<H1>Welcome to Servlets!</H1>\n");
buf.append("</BODY></HTML>");
output.println(buf.toString());
output.close(); // close PrintWriter stream
}
}
<!-- Fig. 19.6: HTTPGetServlet.html -->
<HTML>
<HEAD>
<TITLE>
Servlet HTTP GET Example
</TITLE>
</HEAD>
<BODY>
<FORM
ACTION="http://localhost:8080/servlets/HTTPGetServlet"
METHOD="GET">
<P>Click the button to have the servlet send
an HTML document</P>
<INPUT TYPE="submit" VALUE="Get HTML Document">
</FORM>
</BODY>
</HTML>
Well, it didn't work. My question is, in order to install this simple
servlet does that mean I have to go through all the steps as given in the
documentation for "Developing Applications with Tomcat"?
Cheers and many thanx in advance,
LeRoi