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 | <head> <meta http-equiv= "Content-Type" content= "text/html; charset=EUC-KR" > <title>스크립트 예제</title> </head> <%! String declaration = "Declaration" ; %> <%! public String decMethod() { return declaration; } %> <% String scriptlet = "scriptlet" ; String comment = "comment" ; out.println(declaration+ "<p>" ); %> <%=declaration %><p> <%=decMethod() %><p> <%=scriptlet %> |
결과 순서대로
내장객체
선언문
스클립틀릿
선언문
- 전역변수
- 멤버변수
- <%! %>
1 2 3 4 5 6 7 8 9 | <% String name = team + "Fighting" ; %> <%! String team = "korea" ; %> <%=name %> |
메소드 선언
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <%! int one; int two=1; public int plus() { return one+two; } String msg; int three; %> <%=plus() %> <%=msg %> <%=three %> |
스클립틀릿
- JSP 페이지가 서블릿으로 변환되고, 요청될때 선언
- 지역변수
1 2 3 4 5 6 7 8 | <% float f = 2.3f; int i = Math.round(f); java.util.Date date = new java.util.Date(); %> <%=i %><p> <%=date.toString() %> |
표현식
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <%! String name[] = { "sun" , "java" , "jsp" }; %> <table border=1 width=200> <% for ( int i=0;i<name.length;i++){ %> <tr> <td> <%=i %> </td> <td> <%=name[i] %> </td> </tr> <%} %> </table> |
'Study > JSP' 카테고리의 다른 글
equals 와 "=="의 차이 (2) | 2013.05.28 |
---|---|
제어문 (0) | 2013.05.28 |
ResultSet (0) | 2013.05.23 |
JSP 스클립틀릿 (0) | 2013.05.23 |
[SVN] 오류 Attempted to lock an already-locked dir 해결방안 (0) | 2012.11.13 |