반응형
Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
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 31
Tags
more
Archives
Today
Total
관리 메뉴

비전공개미 개발노트

[JSP] jsp:include에 jsp:param값을 넘기기 본문

프로그래밍/JSP

[JSP] jsp:include에 jsp:param값을 넘기기

비전공개미 2022. 10. 12. 19:38
반응형
SMALL

info.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<table border="1">
  <tr>
    <td>제품번호</td>
    <td>P111</td>
  </tr>
  <tr>
    <td>가격</td>
    <td>10,000원</td>
  </tr>
</table>
<jsp:include page="infoSub.jsp" flush="false">
	//param type의 값 B를 넘긴다
	<jsp:param name="type" value="B" />
</jsp:include>

</body>
</html>

 

 

infoSub.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String type = request.getParameter("type");
if(type == null){ return; }
%>
<br>
<table border="1" bgcolor="#00cccc">
  <tr>
    <td>타입</td>
    <td><b><%=type %></b></td>
  </tr>
  <tr>
    <td>특징</td>
    <td>
    <%
    if(type.equals("A")){
      %>강한 내구성<%
    }else if(type.equals("B")){
      %>뛰어난 대처 능력<%
    }
    %>
    </td>
  </tr>
</table>
</body>
</html>

 

 

[출력]

반응형
LIST
Comments