private void errMsg(String message)
{
System.out.println("Content-type: text/html\n");
System.out.println("<html>");
System.out.println("<head>");
System.out.println("<title>Error</title>");
System.out.println("</head>");
System.out.println("<body>");
System.out.println("<h1>Error</h1>");
System.out.println("<hr>");
System.out.println("<p>");
System.out.println("An internal error occurred.");
System.out.println("The specific error message is shown below:");
System.out.println("<p><pre>" + message + "</pre><p>");
System.out.println("<p>");
System.out.println("<hr>");
System.out.println("</body>");
System.out.println("</html>");
}
private void display()
{
System.out.println("Content-type: text/html\n");
System.out.println("<html>");
System.out.println("<head>");
System.out.println("<title>Environment and User Variables</title>");
System.out.println("</head>");
System.out.println("<body>");
System.out.println("<h1>Environment and User variables</h1>");
System.out.println("<h2>Environment Variables</h2>");
System.out.println("<table>");
for (int i=0; i<22; i++)
{
if (System.getProperty(EnvVar[i]) != null)
{
System.out.println("<tr>");
{
System.out.println("<tr>");
System.out.println("<td align=right>" + EnvVar[i]+":");
System.out.println("<td>" + System.getProperty(EnvVar[i]));
}
else
{
System.out.println("<tr>");
System.out.println("<td align=right>" + EnvVar[i]+":");
System.out.println("<td>NONE");
}
}
System.out.println("</table>");
System.out.println("</body>");
System.out.println("</html>");
System.out.flush();
}
public static void main (String args[])
{
samplejava cgi = new samplejava();
cgi.display();
}
}
Chapter6. Sample programs (in Java, C, and RPG) 93