72 Using VisualAge for Java Enterprise Version 2 to Develop CORBA and EJB Applications
9.3.7 Testing the Web Server
As a simple test to ensure that you have set up the Web server correctly, we
recommend that you create a simple HTML file, and a correspondingly simple
servlet. See Figure 15 for an example of an HTML file, and Figure 16 for an
example of a servlet.
Figure 15. A Simple HTML File: D:\WWW\HTML\Test.html
Figure 16. A Simple Servlet: tea.servlet.DummyServlet
Place the HTML file in the D:\WWW\HTML directory and create the servlet
inside the tea.servlet package in the Travel Expense Application package.
To start the Web server, select the MyWebServer class and run it. Check the
VisualAge for Java console (see Figure 17) to confirm that the Web server
has started correctly. Occasionally, the Web server fails to start correctly. (We
have been unable to determine why.) If you see extra messages after the last
<BODY>
<HEAD>A simple HTML file test</HEAD>
<P><A HREF="servlet/tea.servlet.DummyServlet">A quick servlet test</A>
</BODY>
import java.io.*;
import javax.servlet.http.*;
public class DummyServlet extends javax.servlet.http.HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException
{
response.setContentType("text/html");
PrintWriter pw = new PrintWriter(response.getOutputStream());
pw.println("<TITLE>Test Servlet</TITLE>");
pw.println("<BODY><H2>Lets see now... does this work?</H2>");
pw.println("<P>Yes... I do believe it does!");
pw.println("</BODY>");
pw.flush();
pw.close();
}
}
Environment Configuration 73
line shown in Figure 17, the Web server has not started correctly, and you
should kill it, and restart.
Figure 17. Console Showing Web Server Starting Successfully
As an extra precaution to ensure that the Web server has started correctly,
we urge you to check the debugger (see Figure 18 on page 74) and ensure
that there are two threads for the pluginservice and two threads for the
servletservice.
74 Using VisualAge for Java Enterprise Version 2 to Develop CORBA and EJB Applications
Figure 18. Debugger Thread List Showing Web Server Starting Successfully

Get Using VisualAge for Java Enterprise Version 2 to Develop CORBA and EJB Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.