Fundamentals of JavaTM Servlets: Magercises
Help: Hosting with the Java Web Server

By MageLang Institute

[Help | Solution | API Docs | Expected Output | Course Notes | Magercises | Module Intro]

Help is available for each task, or you can go straight to the solution source code.

Task 1

Compile the HelloWorldServlet2.java file using your favorite Java compiler.

If you are using the JDK, go to the directory with the HelloWorldServlet2.java file and compile with:

javac HelloWorldServlet2.java

Task 2

Move the servlet to the default servlet directory for the JWS. For JWS version 1.1, the default location on a Windows platform is
C:\JavaWebServer1.1\servlets

The batch file copyit.bat is included in the solution directory. It will copy the servlet class file to the correct directory Windows for the JWS. Unix users will have to manually copy the file to the appropriate installation directory.

Task 3

Run the JWS.

Go to the directory:

C:\JavaWebServer1.1\bin

and type the command:

httpd

This will start the JWS and display no additional information on your screen.

Task 4

Use the JWS Servlet Management panel to install the servlet and create the alias HW2.

To run the Java Web Server Administration applet type in the http://localhost:9090 URL in a browser. If the JWS was installed correctly and started running in the previous step, you should now be viewing the Java Web Server Administration applet.

Enter the username "admin" and password "admin" to log on to the server.

Select the running Web Service and click the "Manage" button. This will bring up another applet window. Select the "Servlets" button on the top menu bar. Then select "Add" from the left hand set of choices and enter "HW2" into the "Servlet Name" field and "HelloWorldServlet2" into the "Servlet Class" field before pressing the "Add" button. This will bring up a tabbed panel that you can use to set the servlet's parameters and properties. Press the "Load" button to see if the servlet will load properly.

Task 5

Activate the servlet from your browser by clicking here or by typing the URL
  http://localhost:8080/servlet/HelloWorldServlet2

into your browser.

Task 6

Activate the servlet from your browser by using the alias, HW2, by clicking here or by typing the URL
  http://localhost:8080/servlet/HW2

into your browser.

Copyright © 1998 MageLang Institute. All Rights Reserved.