본문 바로가기
🎵JSP

[JSP] JSTL core를 이용해서 로그인 페이지 만들기(c:when, c:choose)

by 김말자 2023. 2. 14.
728x90
728x90
BIG
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>로 그 인</title>
</head>
<body>
	<form action="loginResult.jsp">
	<table>
		<tr>
			<td>아이디 :</td>
			<td><input type="text" name="id" id="id"></td>
		</tr>
		<tr>
			<td>암 호 :</td>
			<td><input type="password" name="pwd" id="pwd"></td>
		</tr>
		<tr>
		<td colspan="2">
		<input type = "radio" name="admin" value="1">사용자
		<input type = "radio" name="admin" value="2">관리자
		</td>
		</tr>
		
		<tr>
		<td colspan="2">
		<input type = "submit" value="로그인">
		</td>
		</tr>
		
	</table>
	</form>
</body>
</html>

라디오버튼에 코어를 이용해보자~

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String id = request.getParameter("id");
//out.print(id);
%>
${param.id}님
<c:choose>
   <c:when test="${param.admin==1}">
     사용자
     </c:when>
        <c:when test="${param.admin==2}">
     관리자
     </c:when>
     </c:choose>
     로 로그인하셨습니다.
</body>
</html>

728x90
반응형
BIG

댓글