반응형
Notice
Recent Posts
Recent Comments
Link
관리 메뉴

bro's coding

EL.parameter 본문

[IT]/JSP

EL.parameter

givemebro 2021. 4. 22. 16:41
반응형
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>EL parameter</title>
</head>
<body>
	<a href="step2-2.jsp?command=insert&name=아이유">gogo</a>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>EL parameter</title>
</head>
<body>
	1. scriptlet 방식:
	<%=request.getParameter("command")%>
	<%=request.getParameter("name")%>
	<%=request.getParameter("age")%><%-- null 이 출력됨 --%>
	<hr>
	<%-- EL에서 null은 보여주지 않는다 --%>
	2. EL 방식: ${param.command } ${param.name } ${param.age}

	<form action="step2-3.jsp">
		별명<input type="text" name="nick" required="required"><br>
		나이<input type="number" name="age" required="required"><br>
		<input type="submit" value="등록">
	</form>


</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>EL parameter</title>
</head>
<body>
	1. scriptlet 방식:
	<%=request.getParameter("nick")%>
	<%-- 나이에 +1 --%>
	<%
	int age = Integer.parseInt(request.getParameter("age"));
	%>
	<%=age + 1%>
	<%=request.getParameter("age") + 1%>
	<hr>
	2. EL 방식 ${param.nick} ${param.age+1 }
	<%-- EL은 자동 형변환 --%>
</body>
</html>
반응형

'[IT] > JSP' 카테고리의 다른 글

JSTL.if  (0) 2021.04.23
JSTL.taglib  (0) 2021.04.23
EL.ServletContext  (0) 2021.04.23
EL.session  (0) 2021.04.23
EL.Class 접근  (0) 2021.04.23
EL  (0) 2021.04.22
JSP.Sample Code  (0) 2021.04.12
JSP.basic  (0) 2021.04.08
Comments