FileDocCategorySizeDatePackage
WeatherHtml.javaAPI DocExample3223Tue Jan 25 10:45:14 GMT 2000None

WeatherHtml

public class WeatherHtml extends HttpServlet

Fields Summary
static final int
currentTemp
static final String
currentImage
static final String[]
forecastDay
static final String[]
forecastImage
static final int[]
forecastHi
static final int[]
forecastLo
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)


       
                                  
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    // Set its title
    String title = "Sebastopol Weather Forecast";
    out.println("<HTML>");
    out.println("<HEAD>");
    out.println("<TITLE>" + title + "</TITLE>");
    out.println("</HEAD>");

    // Start on the body
    out.println("<BODY>");

    // Make a centered table
    out.println("<CENTER>");
    out.println("<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 WIDTH=70%>");

    // First row
    out.println("<TR>");
    out.println("<TD><CENTER><B>");
    out.println("<FONT SIZE=+2>Current Conditions</FONT>");
    out.println("</B></CENTER></TD>");

    out.println("<TD><CENTEr>");
    out.println("<IMG WIDTH=48 HEIGHT=35 SRC=\"" + currentImage + "\">");
    out.println("</CENTER></TD>");

    out.println("<TD COLSPAN=2><CENTER><B><FONT SIZE=+2>");
    out.println(currentTemp + "°");
    out.println("</FONT></B></CENTER></TD>");
    out.println("</TR>");

    // Second row
    out.println("<TR>");
    out.println("<TD COLSPAN=2><CENTER><B><FONT SIZE=+1>");
    out.println("Extended Forecast");
    out.println("</FONT></B></CENTER></TD>");

    out.println("<TD><CENTER><B><FONT SIZE=+1>");
    out.println("Hi");
    out.println("</FONT></B></CENTER></TD>");

    out.println("<TD><CENTER><B><FONT SIZE=+1>");
    out.println("Lo");
    out.println("</FONT></B></CENTER></TD>");
    out.println("</TR>");

    // Daily forecast rows
    for (int i = 0; i < forecastDay.length; i++) {
      out.println("<TR>");
      out.println("<TD> <FONT SIZE=+1>");
      out.println(forecastDay[i]);
      out.println("</FONT></TD>");
      out.println("<TD><CENTER>");
      out.println("<IMG WIDTH=48 HEIGHT=35 SRC=\"" + forecastImage[i] + "\">");
      out.println("</CENTER></TD>");
      out.println("<TD><CENTER><FONT SIZE=+1>");
      out.println(forecastHi[i]);
      out.println("</FONT></CENTER></TD>");
      out.println("<TD><CENTER><FONT SIZE=+1>");
      out.println(forecastLo[i]);
      out.println("</FONT></CENTER></TD>");
      out.println("</TR>");
    }

    // Close the still-open tags
    out.println("</TABLE>");
    out.println("</CENTER>");
    out.println("</BODY></HTML>");