You are currently using guest access (Login)
Help with Search
 
 
Picture of s10011 ゆーき
POSTとGETを受け取るjava
by s10011 ゆーき - Monday, 15 October 2012, 12:04 PM
 

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

public class Name extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
        response.setContentType("text/html; charset=UTF-8");

        String firstname = request.getParameter("first");
        String secondname = request.getParameter("second");

        PrintWriter out = response.getWriter();
        create(out,firstname,secondname,"GET");
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
        response.setContentType("text/html; charset=UTF-8");

        String firstname = request.getParameter("first");
        String secondname = request.getParameter("second");

        PrintWriter out = response.getWriter();
        create(out,firstname,secondname,"POST");
    }

    public void create(PrintWriter out,String firstname,String secondname,String method){
        out.println("<html>");
        out.println("<head><title>CGI TEST(POST)</title></head>");

        out.println("<body><center><H2>"+method+" Method</H2><br />");
        out.println("<H2>your firstname:"+firstname+"<H2>");
        out.println("<H2>your secondname:"+secondname+"<H2><br>");
        out.println("</center></body>");

        out.println("</html>");

    }
}

Skip Navigation

Navigation


You are currently using guest access (Login)