You are currently using guest access (Login)
Help with Search
 
 
Picture of s10051 dyst
PostGetName.java
by s10051 dyst - Monday, 22 October 2012, 11:17 AM
 

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class GetPostName extends HttpServlet {

String getpost;
String firstname;
String secondname;

   public void doPost(HttpServletRequest request, HttpServletResponse response)
   throws IOException, ServletException{
      response.setContentType("text/html; charset=UTF-8");
      request.setCharacterEncoding("UTF-8");
      firstname = request.getParameter("fname");
      secondname = request.getParameter("sname");
      PrintWriter out = response.getWriter();
      getpost = "POST";
      common(out);
   }


   public void doGet(HttpServletRequest request, HttpServletResponse response)
   throws IOException, ServletException{

      response.setContentType("text/html; charset=UTF-8");

      request.setCharacterEncoding("UTF-8");
      firstname = request.getParameter("fname");
      secondname = request.getParameter("sname");
      PrintWriter out = response.getWriter();
      getpost = "GET";
      common(out);
   }

   public void common(PrintWriter out) throws IOException{
      out.println("<html>");
      out.println("<head>");
      out.println("<title>" +getpost+ " Name</title>");
      out.println("</head>");
      out.println("<body>");
      out.println("<h1>" +getpost+ " Method</h1>");
      out.println("<br>");

      out.println("<h2>あなたのファーストネームは ");
      out.println("<font color=#C01010>"+firstname+"</font></h2>");
      out.println("<h2>あなたのセカンドネームは ");
      out.println("<font color=#C01010>"+secondname+"</font></h2>");
      out.println("</body>");
      out.println("</html>");
   }
}

Skip Navigation

Navigation


You are currently using guest access (Login)