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("/01.HelloJsp/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> <% } %>
<%@ 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>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import ="java.net.URLEncoder" %> <% String value = "I LIKE JAVA "; String encodedValue = URLEncoder.encode(value, "UTF-8"); response.sendRedirect("/01.HelloJsp/main.jsp?name=" + encodedValue); %>
<%@ 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>
redirectEncodingTest.jsp실행 화면
'JSP > 기본(Oracle)' 카테고리의 다른 글
배포 구조 (0) | 2012.05.30 |
---|---|
autoFlush 설정(true,false) (0) | 2012.05.30 |
JSP 리다이렉트(redirect)이용해서 페이지 이동하기 (0) | 2012.05.30 |
JSP 헤더 목록 출력(Enumeration) (0) | 2012.05.30 |
request 기본 객체의 파라미터 읽기 메서드 (0) | 2012.05.30 |