티스토리 뷰

JSP

[JSP] 액션태그

먹태 2018. 7. 10. 16:44

1. foward 

- 현재 페이지에서 다른 특정페이지로 전환할때 사용

<jsp:forward page="파일이름.jsp"/>




2. include 

- 현재페이지에 다른 페이지를 삽입할 때 사용

<jsp: include page="파일이름.jsp"/>




3. param

- foward및 include 태그에 데이터 전달을 목적으로 사용되는 태그

- 이름과 값으로 이루어져 있다

- 값을 함께 넘긴다고 생각하면 됨


<jsp:foward page = "파일이름.jsp">

     <jsp:param name="id" value="asdf">

     <jsp:param name="pw" value="123">

</jsp:forward>






<fo.jsp>


  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2.     pageEncoding="UTF-8"%>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <title>Insert title here</title>
  8. </head>
  9. <body>
  10.     <jsp:forward page="fo2.jsp">
  11.         <jsp:param name="id" value="hong"/>
  12.         <jsp:param name="pw" value="1234"/>
  13.     </jsp:forward>
  14.  
  15. </body>
  16. </html>




<fo2.jsp>


  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2.     pageEncoding="UTF-8"%>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <title>Insert title here</title>
  8. </head>
  9. <body>
  10.  
  11.     <%!
  12.         String name, id, pw;
  13.     %>
  14.    
  15.     <%
  16.         id = request.getParameter("id");
  17.         pw = request.getParameter("pw");
  18.     %>
  19.  
  20.     <h2>회원정보</h2>
  21.     id  : <%=id %><br/>
  22.     비밀번호  : <%=pw %><br/>
  23. </body>
  24. </html>






댓글
최근에 올라온 글
최근에 달린 댓글
링크
Total
Today
Yesterday