• JSP 페이지에서 자동으로 생성되고 사용할 수 있는 객체들을 말함

request

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>Insert title here</title>
</head>
<body>
	<form method="post" action="proc.jsp">
		<label for="id">아이디:</label>
		<input type="text" id="id" name="id"><br>

		<label for="passwd">비밀번호:</label>
		<input type="password" id="passwd" name="passwd"><br>

		<input type="submit" value="로그인">
	</form>

</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>Insert title here</title>
</head>
<body>
<form>
<%
	request.setCharacterEncoding("UTF-8");
	String userId = request.getParameter("id");
	String password = request.getParameter("passwd");
%>

	<p> 아이디: <%=userId %></p>
	<p> 비밀번호: <%=password %></p>
	
</form>
</body>
</html>
  • 사용자 요구 사항을 얻어내는 것이 목적 ex: form 태그를 통해 들어오는 id, password 정보
  • JSP 컨테이너는 웹 브라우저에서 서버로 전달되는 정보를 처리하기 위해 request안에 저장된 정보를 가져오는 메소드들을 가지고 있
    • request.setCharacterEncoding("UTF-8");
    • request.getHeader("name")
    • request.getCookies()
    • request.getParameter("id");

  • 서버의 JSP페이지로 전달하는 정보를 저장하는 객체

'Development > JSP' 카테고리의 다른 글

유효성 검사  (0) 2023.05.10
파일 업로드  (0) 2023.05.09
자바 빈즈  (0) 2023.04.19
액션 태그  (0) 2023.04.19
서블릿과 JSP  (0) 2023.04.19

+ Recent posts