화면분할(파일분할)
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!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=UTF-8"> <title>Insert title here</title> </head> <body topmargin="0" leftmargin="0"> <% String name="test"; %> <table border="1" width="1000" height="700"> <tr> <td colspan="2" height="100" bgcolor="blue"><jsp:include page="top.jsp"/></td> </tr> <tr> <td width="150" bgcolor="red"><jsp:include page="menu.jsp"/></td> <td bgcolor="yellow"><jsp:include page="content.jsp"> <jsp:param value="<%=name %>" name="name"/> </jsp:include></td> </tr> </table> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!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=UTF-8"> <title>Insert title here</title> </head> <body> <h1>Top</h1> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!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=UTF-8"> <title>Insert title here</title> </head> <body> <h1>Menu</h1> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!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=UTF-8"> <title>Insert title here</title> </head> <body> <%=request.getParameter("name") %> <h1>Content</h1> </body> </html>
실질적으로 어떻게 동작하는지
jsp파일을 컴파일하면 java파일이 되는건 알지..
어떻게 java파일로 변환되는지 보면..
C:\Java\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\webdev\org\apache\jsp\beans 보면
클래스 파일이 따로따로 만들어져있지. 각각의 페이지인거야. 변수값 공유 같은건 당연히 안되지.. 완전히 모듈화된거지..
다른 방법은 jsp자체에서 include tag를 쓰는 방법이 있지..
content.jsp, main.jsp, menu.jsp, top.jsp 를 /webdev/WebContent/basic 에 복사하고.. main.jsp 수정
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!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=UTF-8"> <title>Insert title here</title> </head> <body topmargin="0" leftmargin="0"> <% String name="test"; %> <table border="1" width="1000" height="700"> <tr> <td colspan="2" height="100" bgcolor="blue"><%@ include file="top.jsp" %></td> </tr> <tr> <td width="150" bgcolor="red"><%@ include file="menu.jsp" %></td> <td bgcolor="yellow"><%@ include file="content.jsp" %></td> </tr> </table> </body> </html>
C:\Java\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\webdev\org\apache\jsp\basic 보면
main_jsp.java하나뿐이네..
모듈화는 아니지만 변수를 공유한다던가 하는게 쉽지..
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!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=UTF-8"> <title>Insert title here</title> </head> <body> <%=name%> <h1>Content</h1> </body> </html>
HTML자체에서도 프레임을 나눌 수 있었어 frame tag로
근데 HTML5부터는 frame이 없어져 버렸어..
'Java, Spring > 08일' 카테고리의 다른 글
8일차 1 - Java Beans (0) | 2012.09.20 |
---|---|
8일차 3 - session (0) | 2012.09.20 |
8일차 4 - Cookie (1) (0) | 2012.09.20 |
8일차 5 - Cookie (2) (0) | 2012.09.20 |
8일차 6-2 - login Model2로 만들기 (1) (0) | 2012.09.20 |