Wrox Home  
Search P2P Archive for: Go

  Return to Index  

servlets thread: Help for another servlet newby


Message #1 by peterfrb2@y... on Thu, 29 Nov 2001 19:45:09
Hello and help!

I need some serious hand holding to get me up and running with servlets.  
I purchased two books on the subject: "Professional Java Server 
Programming", published by Wrox; and "Java Examples in a Nutshell", 
published by O'Reilly.  And I really don't know what I'm doing.

I wish to run Servlets on a Windows 2000 machine.  With instructions from 
PJSP, I downloaded the servlet package from Sun.  The file I downloaded 
was "servlet-2_3-fcs-classfiles.zip", in the directory 
http://java.sun.com/products/servlet/download.html.  The files I got were 
in three directories, javax/servlet/http.  Then I attempted to compile the 
following "Hello World" program they provided:

-----------------------
// Import Servlet Libraries
import javax.servlet.*;
import javax.servlet.http.*;

//Import java Libraries
import java.io.*;

public class HelloWorld extends HttpServlet
{
    public void doGet(HttpServletRequest req, HttpServletResponse res) 
                      throws ServletException, IOException
    {
        res.setContentType("text/html");
        PrintWriter out = res.getWriter();

        out.println("<HTML>");
        out.println("<HEAD>");
        . . . Finish generating html document with "Hello World" in 
            the body.
        out.println("</HTML>");

        out.close();
    }
}
-----------------------

I could not get the compiler to recognize the javax class files, and this 
problem persisted no matter where I placed the javax directory.  I tried 
placing it directly under the root and beneath my Java (c:\jdk1.3.1_01)
directories, to no avail.  

Then I turned to my other book, JEIAN, and they recommended going to 
Tomcat's website, http://jakarta.apache.org, and this time I downloaded 
jakarta-tomcat-4.0.1.exe.  This download has a richer set of files and 
directories, downloaded to "C:\Program Files\Apache Tomcat 4.0", but 
there's no help file (*.hlp) in the bunch. 

Still I flounder.  Questions: 1) Do either of the programs I downloaded 
come with decent documentation for neophytes?  2) How do I get the java 
compiler to recognize my javax files and successfully compile my program?  
3) Which download is better for my situation: Sun or Tomcat?  And the 
second phase: 4) Where do I place the successfully compiled file to get my 
browser to recognize it?  5) When I get beyond "Hello World", do I have to 
worry about Explorer and Netscape treating the compiled files differently?

Thank you.
Peter Ferber

  Return to Index