2010. 4. 9. 14:03ㆍprogramming/jsp
4. input_id.jsp에서 ID와 패스워드, 성별을 입력 받고, 입력 받은 결과를 input_id_rst.jsp에서 출력하는 프로그램을 작성하시오.
<%-- input_id.jsp --%>
<%@page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!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=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<Form Action = "input_id_rst.jsp" Method = "post">
아이디 : <Input Type = "test" Name = "id"> <BR>
<hr align=left width=300>
비밀번호 : <Input Type = "password" Name = "pass"> <BR>
<hr align=left width=300>
성 별 :남<input type=radio name=gender checked value="남">
여<input type=radio name=gender value="여" >
<Br>
<hr align=left width=300>
<Input Type = "Submit" Value = "로그인">
<Input Type = "Reset" Value = "취소">
<hr align=left width=300>
</Form>
</body>
</html>
<%-- input_id_rst.jsp --%>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!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=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<% request.setCharacterEncoding("euc-kr"); %>
<%
String id = request.getParameter("id");
String pass = request.getParameter ("pass");
String gender = request.getParameter("gender");
if ("a".equals(id)){
if("a".equals(pass)){
%>
<%
} else {
out.println("<script> alert('비밀번호를 확인하세요');history.go(-1);</script>");
}
} else {
out.println("<script> alert('아이디를 확인하세요');history.go(-1);</script>");
}
%>
<table border=1>
<tr>
<td>아이디</td>
<td><%=id %></td>
</tr>
<tr>
<td>비밀번호</td>
<td><%=pass %></td>
</tr>
<tr>
<td>성별</td>
<td><%=gender%></td>
</tr>
</table>
</body>
</html>
'programming > jsp' 카테고리의 다른 글
JSP 실습 6 (include 태그) (0) | 2010.04.09 |
---|---|
JSP 실습 5 (연산) (0) | 2010.04.09 |
포워드(forward)와 리다이렉트(redirect) 차이 (0) | 2010.04.07 |
response.sendRedirect()와 forward 액션의 차이점 (0) | 2010.04.07 |
response 페이지 이동 (sendRedirect) (0) | 2010.04.07 |