You are currently using guest access (Login)
Help with Search
 
 
Picture of s10185 (・ω・)
PostGetName
by s10185 (・ω・) - Monday, 22 October 2012, 11:59 AM
 

http://192.168.121.152/tomcat/PostGetName.html

 

 

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Date;
public class PostGetName extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
        response.setContentType("text/html; charset=UTF-8");
        String firstname = request.getParameter("fname");
        String secondname = request.getParameter("sname");
        PrintWriter out = response.getWriter();
        name(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("fname");
        String secondname = request.getParameter("sname");
        PrintWriter out = response.getWriter();
        name(out,firstname,secondname,"POST");
    }
    public void name(PrintWriter out,String firstname,String secondname,String method){
    out.println("<HTML>");
    out.println("<HEAD>");
    out.println("<TITLE>Your Name</TITLE>");
    out.println("</HEAD>");
    out.println("<BODY>");
    out.println("<H1>"+ method +" 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)