12.1 HTML Forms

<html><head><title></title></head>  
<body>Hello form</body></html>

<..form.html..>
 <html>  <head><title></title> </head>
 <body>
 <p class="noindent">A sample form:</p>
 
 <form
     action="http://gurari.cis.ohio-state.edu/servlet/FormServlet"
     method="get">
   <input type="submit" value="GET request" />
 </form>
 
 <form
     action="http://gurari.cis.ohio-state.edu/servlet/FormServlet"
     method="post">
   <input type="submit" value="POST request" />
 </form>
 
 </body></html>
-_-_-

<..FormServlet.java..>
 import java.io.*;
 import java.util.*;
 import javax.servlet.*;
 
 public class FormServlet implements Servlet {
   public void service(ServletRequest req, ServletResponse res)
                            throws  ServletException, IOException {
     res.setContentType( "text/html" );
     PrintWriter out = res.getWriter();
     out.println( "<html><head><title></title></head>" );
     out.println( "<body>Hello form</body></html>" );
     out.close();
   }
 
   private ServletConfig config;
   public void init (ServletConfig config) throws ServletException {
     this.config = config;
   }
   public void destroy() {}
   public ServletConfig getServletConfig() { return config; }
   public String getServletInfo() { return "";}
 }
-_-_-