Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 오버로딩
- Android
- 어노테이션
- 에러페이지
- 생성자
- oracle
- AWT
- 전화걸기
- 이클립스
- Java
- 메서드
- Eclips
- Graphic
- Menu
- 메소드
- OGNL
- layout
- 안드로이드
- paint
- JSP
- 배열
- mybatis
- JavaScript
- 국제화
- 클래스
- struts2
- HTML
- Spring
- 기본
- 예외처리
Archives
- Today
- Total
note
리다이렉트(Redirect)를 이용해서 페이지 이동하기2 본문
login.jsp 실행시
login으로 넘어 갈경우
login.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String id = request.getParameter("memberId");
if (id != null && id.equals("era13")) {
response.sendRedirect("/chap03/index.jsp");
} else {
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>로그인 실패</title>
</head>
<body>
아이디가 era13이 아닙니다.
</body>
</html>
<%
}
%>
index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>login</title>
</head>
<body>
아이디가 era13 입니다.
</body>
</html>
redirectEncodingTest.jsp실행 화면
redirectEncodingTest.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import ="java.net.URLEncoder" %>
<%
String value = "자바";
String encodedValue = URLEncoder.encode(value, "UTF-8");
response.sendRedirect("/chap03/main.jsp?name=" + encodedValue);
%>
main.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>main.jsp</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String name = request.getParameter("name");
%>
<%=name%>
</body>
</html>
'JSP > 기본' 카테고리의 다른 글
| 배포 구조 (0) | 2012.02.06 |
|---|---|
| autoFlush 설정(true,false) (0) | 2012.02.06 |
| JSP 리다이렉트(redirect)이용해서 페이지 이동하기 (0) | 2012.02.06 |
| JSP 헤더 목록 출력(Enumeration) (0) | 2012.02.06 |
| request 기본 객체의 파라미터 읽기 메서드 (0) | 2012.02.06 |