[JavaSpring] servlet post방식
컴퓨터/JSP
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
public class PostServlet4 extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String id = request.getParameter("id");
String pw = request.getParameter("pw");
String email = request.getParameter("email");
response.setContentType("text/html; charset=utf-8");
PrintWriter out = response.getWriter();
out.print("<html>");
out.print("<body>");
out.print("<h1>Post Servlet 방식</h1>");
out.print("<h3>id : " + id + "</h3>");
out.print("<h3>pw : " + pw + "</h3>");
out.print("<h3>email : " + email + "</h3>");
out.print("</body>");
out.print("</html>");
}
}
jsp 파일
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>Post Servlet 방식</h1>
<form action="PostServlet" method="post">
ID : <input name="id"><p/>
PW : <input type="password" name="pw"><p/>
EMAIL : <input name="email"><p/>
<input type="submit" value="회원가입">
</form>
</body>
</html>'컴퓨터 > JSP' 카테고리의 다른 글
| [JavaSpring] 자바 빈으로 회원가입 페이지 만들기 (0) | 2024.07.17 |
|---|---|
| [JavaSpring] servlet 로그인 로그아웃 (0) | 2024.07.17 |
| [JavaSpring] servlet get방식 (0) | 2024.07.17 |
| [JavaSpring] servlet (0) | 2024.07.17 |
| [JavaSpring] config (0) | 2024.07.16 |



