> From: "Steve R Burrus" <[EMAIL PROTECTED]>
> Sent: Tuesday, January 14, 2003 12:57 PM
> Subject: RE: servlet with Tomcat


> Nicole, that's really fine and good that you bothered to send me a web
page that
> purportedly offers me some free advice on how the hell I go about
seeing/viewing a
> compiled servlet, BUT I really thought that you could, if you would
please,
> directly give some help on editing that web.xml file!

Be careful what you wish for Mr. Burrus, you just may get it.

0. Format your system and install a recent release of Windows 2000(this step
is optional -- although I'm afraid it may not be for you)

1. Download J2SE SDK for Windows
(http://java.sun.com/j2se/1.3/download.html), and install it. Place it in
C:\JDK1.3.1 when it asks for a destination. This is JAVA_HOME

2. Download latest binary of Tomcat
(http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.1.18/bin/jak
arta-tomcat-4.1.18.zip). Unzip this at C:, and it creates
C:\jakarta-tomcat-4.1.18. This is CATALINA_HOME

3. Download and install from http://www.cygwin.com/setup.exe. (You need this
to use the vi editor later on). Install in in C:\CYGWIN

3. Open a DOS Command Prompt

4. Type: SET JAVA_HOME=C:\JDK1.3.1

5 Type: SET PATH=%PATH%;C:\CYGWIN\BIN;%JAVA_HOME%\BIN

6 Type: SET CATALINA_HOME=C:\jakarta-tomcat-4.1.18

7 Type: CD %CATALINA_HOME%\webapps\examples\WEB-INF\classes

8. Create a new file here: HelloSteve.java, and place the following code in
it. Note that <ENTER> and <ESC> are the actual ENTER key and ESC keys on
your keyboard.
Type: vi HelloSteve.java
i (to enter insert mode in vi)
import java.io.*;<ENTER>
import java.text.*;<ENTER>
import java.util.*;<ENTER>
import javax.servlet.*;<ENTER>
import javax.servlet.http.*;<ENTER>
<ENTER>
public class HelloSteve extends HttpServlet {<ENTER>
    public void doGet(HttpServletRequest request,<ENTER>
                      HttpServletResponse response)<ENTER>
        throws IOException, ServletException<ENTER>
    {<ENTER>
        response.setContentType("text/html");<ENTER>
        PrintWriter out = response.getWriter();<ENTER>
<ENTER>
        out.println("<html>");<ENTER>
        out.println("<head>");<ENTER>
        out.println("<title>Hi! My name is Steve!</title>");<ENTER>
        out.println("</head>");<ENTER>
        out.println("<body>");<ENTER>
        out.println("<B>Hi! My name is Steve Burrus!</B><br>");<ENTER>
        out.println("I tend to be <i>abusive, ignorant, and
untrainable.</i><br>");<ENTER>
        out.println("I appear to suffer from docuphobia, a distinct
affliction that prevents me from");<ENTER>
        out.println("reading documentation<br>");<ENTER>
        out.println("</body>");<ENTER>
        out.println("</html>");<ENTER>
    }<ENTER>
}<ENTER>
<ESC>:wq!

9. Type: javac -classpath %CATALINA_HOME%\common\lib\servlet.jar
HelloSteve.java

10. Ok, here's the crown jewels. "Direct help" on editing web.xml. Now, I'm
using the vi editor here, again, because it's the easiet one to follow along
with. So, stay close and do what I do exactly.

Type: cd .. (this takes you to %CATALINA_HOME\webapps\examples\WEB-INF)
Type: vi web.xml<ENTER>
/<servlet><ENTER>
4yyP8wcwHelloSteve<ESC>
11wcwHelloSteve<ESC>
/let-map<ENTER>
4yyP10wcwHelloSteve<ESC>
11whxdwxxi/HelloSteve<ESC>
:wq!<ENTER>

Ok, now you've changed the web.xml file.

Type: cd ..\..\..\bin (gets you to the bin directory for tomcat)
Type: catalina.bat run (starts tomcat in your shells window) Let Tomcat
start up. Wait for this line:
[INFO] Http11Protocol - -Starting Coyote HTTP/1.1 on port 8080

Now, open a browser and use this URL:
http://localhost:8080/examples/HelloSteve

There ya go, your own servlet.

Everything you asked for. It really can not get any more detailed than this.
Truly. Just follow along VERY CAREFULLY and this will work just peachy.

HTH

Regards,

Will Hartung
([EMAIL PROTECTED])




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to