일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 배열
- 반복문
- 대덕인재개발원
- Android
- 단축키
- 맥
- crud
- 컬렉션프레임워크
- servlet
- API
- JDBC
- pyqt
- 객체지향
- Mac
- 이클립스
- Homebrew
- 생활코딩
- ibatis
- jsp
- ddit
- spring
- FastAPI
- 자바문제
- html
- 자바
- Oracle
- Error
- Java
- nodejs
- python
Archives
- Today
- Total
romworld
JSP 08 - response 본문
페이지 이동 = 리다이렉션(redirection)
- 페이지를 강제로 이동하는 것
response 연습
<response01.jsp>
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<title>Implicit Objects</title>
</head>
<body>
<!--
response01_process.jsp?id=a001&passwd=java
-->
<form action="response01_process.jsp" method="post">
<!-- required : 필수 입력 -->
<p> 아이디 : <input type="text" name="id" required /></p>
<p> 비밀번호 : <input type="password" name="passwd" required/></p>
<p><input type="submit" value="전송"></p>
</form>
</body>
</html>
<response01_process.jsp>
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<title>Implicit Objects</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String userId = request.getParameter("id");
String password = request.getParameter("passwd");
out.print("<p>userId : " + userId +"</p>");
out.print("<p>password : " + password+"</p>");
// userId값이 a001이면서 동시에 password 값이 java인 경우
// response01_success.jsp로 강제 재요청
// 아닌 경우 response01_failed.jsp로 강제 재요청
if(userId.equals("a001") && password.equals("java")){
response.sendRedirect("response01_success.jsp");
}else{
response.sendRedirect("response01_failed.jsp");
}
%>
</body>
</html>
- 성공일 경우 response01_success.jsp 로 이동
- 실패일 경우 response01_failed.jsp 로 이동
<response01_success.jsp>
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<title>Implicit Object</title>
</head>
<body>
로그인 성공 !
</body>
</html>
<response01_failed.jsp>
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<title>Implicit Objects</title>
</head>
<body>
로그인 실패!
</body>
</html>
페이지 새로고침
response.setIntHeader("Refresh", 초);
'WEB > JSP' 카테고리의 다른 글
JSP 10 - 쇼핑몰 사이트 만들기(3) [상품 상세 정보] (0) | 2022.12.29 |
---|---|
JSP 09 - out (0) | 2022.12.28 |
JSP 07 - request (0) | 2022.12.28 |
JSP 06 - 쇼핑몰 사이트 만들기(2), ERWin (0) | 2022.12.26 |
JSP 05 - 디렉티브 태그 ( taglib02 ) (0) | 2022.12.26 |
Comments