Листинг 9.26. Метод doGet создает простую форму (NetNewsServ.java)
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/html"); PrintWriter out = new PrintWriter(resp.getOutputStream());
out.println("<HTML> "); out.println("<HEAD> <TITLE> NetNewsServ Output</TITLE> </HEAD> "); out.println("<BODY> "); try { NetNewsBean nnb = new NetNewsBean( queryStr, destDir, queryFile );
out.println("<h1> The News</h1> "); out.println("<p> Select the general categories you would like to see. "+ "You can also enter a list of key words or phrases separated by " + "commas and the system will locate any headlines containing them.</p> " ); out.println("<center> <form method=\"POST\" action=\"" + alias + "\" > " ); out.println("Key Words: <input type=\"TEXT\" size=\"60\"" + " maxlength=\"120\" name=\"keywords\" > <br> "); out.println("Select one or more topics (use <ctrl>click.) <br> "); out.println( nnb.getTopicsAsSelect() ); out.println("<br> <input type=\"SUBMIT\" value=\"Continue\" > "); out.println("</form> </center> <br> "); footer( out ); }catch(Exception e){ errorMsg( out, "NetNewsServ.doGet ", e ); } }