import java.io.*; import java.text.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class WeatherHtml extends HttpServlet { // Some static final variables to populate the page... // These would normally come from a database or // maybe another servlet that retrieved it as POST data. static final int currentTemp = 70; static final String currentImage = "../images/rainy.gif"; static final String[] forecastDay = { "Thursday", "Friday", "Saturday" }; static final String[] forecastImage = { "../images/sunny.gif", "../images/sunny.gif", "../images/rainy.gif" }; static final int[] forecastHi = { 82, 82, 73 }; static final int[] forecastLo = { 58, 65, 48 }; public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); // Set its title String title = "Sebastopol Weather Forecast"; out.println(""); out.println(""); out.println("" + title + ""); out.println(""); // Start on the body out.println(""); // Make a centered table out.println("
"); out.println(""); // First row out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); // Second row out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); // Daily forecast rows for (int i = 0; i < forecastDay.length; i++) { out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); } // Close the still-open tags out.println("
"); out.println("Current Conditions"); out.println("
"); out.println(""); out.println("
"); out.println(currentTemp + "°"); out.println("
"); out.println("Extended Forecast"); out.println("
"); out.println("Hi"); out.println("
"); out.println("Lo"); out.println("
 "); out.println(forecastDay[i]); out.println("
"); out.println(""); out.println("
"); out.println(forecastHi[i]); out.println("
"); out.println(forecastLo[i]); out.println("
"); out.println("
"); out.println(""); } }