20..29 1: PM ` 199 ntech4 C9600 2400DPI 175LPI T CHAPTER 4
20..29 1: PM ` 200 ntech4 C9600 2400DPI 175LPI T CHAPTER 4.1 JSP (Comment) HTML JSP 3 home index jsp HTML JSP 15 16 17 18 19 20 <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN <title>jsp </title> <b>[ ]</b><br> <%! // private String method = ; private String mymethod() { return method; } %> 200
20..29 1: PM ` 2 ntech4 C9600 2400DPI 175LPI T 4.1 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 <b>[ ]</b><br> <% String str = JSP ; int i = 2; int j = 5; out.println( str \ + str + \.<br> ); out.println( i = + i + <br> ); out.println( j = + j + <br> ); out.println( i + j = ); out.println(i + j + <br> ); out.println( method : + method + <br> ); out.println( mymethod() : + mymethod()); %> <br><br> <b>[ ]</b><br> str <%= str %>.<br> i = <%=i %><br> j = <%=j %><br> i + j = <%=i+j %><br> method : <%= method %><br> mymethod() : <%= mymethod() %> <br><br> <b>[ ]</b><br> <!-- html --> <%-- JSP <%= str %> --%> <% // /* */ %> 46 HTML 47 JSP // /* */ 2
20..29 1: PM ` 2 ntech4 C9600 2400DPI 175LPI T CHAPTER [ ] localhost IP (http://192 168 1 1:80/home/index jsp) HTML JSP 2
20..29 1: PM ` 2 ntech4 C9600 2400DPI 175LPI T 4.2 4.2 (Directive) JSP (request) JSP (response) JSP ( ) JSP 3 @ (at) 4.2.1 page JSP <%@ page 1= 1 2= 2 %> 2
20..29 1: PM ` 2 ntech4 C9600 2400DPI 175LPI T CHAPTER 4.2.1.1 info <%@ page info= www.lug.or.kr %> 4.2.1.2 language JSP java <%@ page language= java %> 4.2.1.3 contenttype JSP MIME text/html text/plain text/xml text/gif text/html MIME <%@ page contenttype= text/html %> JSP charset ISO 8859 1 UTF 8(utf 8) <%@ page contenttype= text/html ; charset= UTF-8 %> this.getservletinfo() info <%@ page info= www.lug.or.kr language= java contenttype= text/html; charset=utf-8 <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN 2
20..29 1: PM ` 2 ntech4 C9600 2400DPI 175LPI T 4.2 <title>page </title> <%=this.getservletinfo() %> 4.2.1.4 JSP JSP Servlet JSP Servlet extends JSP <%@ page extends= kr.or.lug.directive %> <%-- kr.or.lug.directive --%> 4.2.1.5 import JAVA import JSP package import page <%@ page import= java.util.*, java.text.* import= java.io.* %> <%-- (,). --%> <%-- import. --%> 4.2.1.6 session JSP HttpSession true false true false 2
20..29 1: PM ` 2 ntech4 C9600 2400DPI 175LPI T CHAPTER true false <%@ page session= false %> 4.2.1.7 JSP out 8kb none JSP <%@ page buffer= 16kb %> <%@ page buffer= none %> buffer none <jsp:forward > 4.2.1.8 flush (full) (empty) autoflush ( ) true buffer false (OverFlow) (Exception) buffer none autoflush false true <%@ page autoflush= true %> <%@ page buffer= 1kb autoflush= false %> <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN 2
20..29 1: PM ` 2 ntech4 C9600 2400DPI 175LPI T 4.2 15 16 17 18 19 20 <title>autoflush </title> <% for (int i = 0; i <= 00 ; i++) { %> JSP <% } %> buffer 1kb autoflush false JSP buffer Overflow autoflush true 2
20..29 1: PM ` 2 ntech4 C9600 2400DPI 175LPI T CHAPTER 4.2.1.9 ( ) isthreadsafe true <%@ page isthreadsafe= true %> 4.2.1. errorpage JSP <%@ page errorpage= error.jsp %> iserrorpage JSP 2
20..29 1: PM ` 2 ntech4 C9600 2400DPI 175LPI T 4.2 false errorpage JSP iserrorpage true <%@ page iserrorpage= true %> 15 16 17 18 19 20 21 pageencoding= UTF-8 errorpage= /directive/error.jsp %> <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN <title> </title> <% int a = ; int b = 0; %> a b <br> a + b = <%=a + b %><br> a - b = <%=a - b %><br> a * b = <%=a * b %><br> a / b = <%=a / b %><!-- 0 --> JSP page errorpage /directive/error jsp home 19 a 0 Arithmetic Exception error jsp pageencoding= UTF-8 iserrorpage= true %> <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN 2
20..29 1: PM ` 2 ntech4 C9600 2400DPI 175LPI T CHAPTER 15 16 <title>!</title> <h1>exception Error!</h1>.<br> <%=exception.getmessage() %><br> <%=pagecontext.geterrordata().getthrowable().tostring() %> /derective/error jsp page iserrorpage true body pagecontext // exception exception.getmessage() // pagecontext ErrorData pagecontext.geterrordata().getthrowable().tostring() 4.2.1. pageencoding JSP ISO 8859 1 UTF 8 <%@ page pageencoding= UTF-8 %> pageencoding contenttype charset <%@ page pageencoding= UTF-8 contenttype= text/html %> <%@ page contenttype= text/html ; charset= UTF-8 %> 2
20..29 1: PM ` 2 ntech4 C9600 2400DPI 175LPI T 4.2 4.2.2 include file <%@ include file= %> include JSP JSP 2 include include 2 top jsp bottom jsp include top jsp bottom jsp 15 <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN <title>include </title> top : <%@ include file= top.jsp %> <hr>include.jsp.<hr> bottom : <%@ include file= bottom.jsp %> <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN 2
20..29 1: PM ` 2 ntech4 C9600 2400DPI 175LPI T CHAPTER <title>top </title> top.<br> <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN <title>bottom </title> <br>bottom. include? /WebContent/WEB INF/web xml 2
20..29 1: PM ` 2 ntech4 C9600 2400DPI 175LPI T 4.2... <jsp-config> <jsp-property-group> <url-pattern>/directive/*</url-pattern> <include-prelude>/directive/top.jsp</include-prelude> <include-coda>/directive/bottom.jsp</include-coda> </jsp-property-group> </jsp-config> </web-app> web xml /directive * <include prelude> top jsp <include coda> bottom jsp web xml /directive page jsp top jsp bottom jsp web xml page jsp web xml 4.2.3 taglib JSP URI Prefix URI TLD(Tag Library Descriptor) TLD XML TLD Prefix JSP XML <%@ taglib uri= /META-INF/mytag.tld prefix= mytag %> 2
20..29 1: PM ` 2 ntech4 C9600 2400DPI 175LPI T CHAPTER <%@ taglib uri= /META-INF/mytag.tld prefix= mytag %> <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN <title>taglib : </title> <mytag:getinfo name= myinfo /> <mytag:getinfo name= myinfo /> mytag tld GetInfo name myinfo mytag tld GetInfo name myinfo 2
20..29 1: PM ` 215 ntech4 C9600 2400DPI 175LPI T 4.3 JSTL(JSP Standard Tag Library) taglib 4.3 JSP JSP <jsp: /> 6 4.3.1 include include include include HTML JSP Servlet include include flush true <jsp:include page= flush= true /> 215
20..29 1: PM ` 216 ntech4 C9600 2400DPI 175LPI T CHAPTER 15 16 17 18 <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN <title>include </title> <h1>include </h1> <form method= post action= includetag.jsp > : <input type= text name= name ><br> : <input type= text name= nation ><br><br> <input type= submit value= > </form> <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN 216
20..29 1: PM ` 217 ntech4 C9600 2400DPI 175LPI T 4.3 15 16 17 18 19 <title>includetag.jsp</title> <% request.setcharacterencoding( utf-8 ); // String name = JSP ; // %> <jsp:include page= includetagheader.jsp flush= true /> <hr> include body. include jsp name nation utf 8 name name include 15 16 17 <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN <title>includetagheader.jsp</title> include header.<p> <h2> = <%=request.getparameter( name ) %> <br> = <%=request.getparameter( nation ) %> </h2> include jsp include jsp name nation includetagheader jsp JSP 217
20..29 1: PM ` 218 ntech4 C9600 2400DPI 175LPI T CHAPTER JSP include <jsp:param name= value= /> <jsp:include page= flush= true > <jsp:param name= value= /> <jsp:param name= value= /> </jsp:include> <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN <title>include 2</title> <h1>include 2</h1> <form method= post action= includetag2.jsp > : <input type= text name= language ><br><br> 218
20..29 1: PM ` 219 ntech4 C9600 2400DPI 175LPI T 4.3 15 16 17 <input type= submit value= > </form> language includetag2 jsp JSP 15 16 17 18 19 20 21 22 23 <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN <title>includetag2.jsp</title> <% request.setcharacterencoding( utf-8 ); %> <jsp:include page= includetagheader2.jsp > <jsp:param name= language value= PHP /> </jsp:include> <hr> <b> request parameter : <%=request.getparameter( language ) %> </b><br> include body. utf 8 <jsp:include > includetagheader2 jsp language PHP 19 language JSP <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN 219
20..29 1: PM ` 220 ntech4 C9600 2400DPI 175LPI T CHAPTER 15 16 <title>includetagheader2.jsp</title> include header.<p> <h2> = <%=request.getparameter( language ) %> </h2> includetagheader2 jsp language includetag2 jsp include PHP <jsp:include > include 220
20..29 1: PM ` 221 ntech4 C9600 2400DPI 175LPI T 4.3 4.3.2 forwad include JSP JSP forward <jsp:forward page= /> <jsp:forward page= ></jsp:forward> <jsp:forward page= <%=expression %> /> 221
20..29 1: PM ` 222 ntech4 C9600 2400DPI 175LPI T CHAPTER forward 4 15 forward forward 15 16 17 18 <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN <title>forward </title> <h1>forward </h1> <form method= post action= forwardtag.jsp > ID : <input type= text name= id ><br> PASSWORD : <input type= password name= pass ><br><br> <input type= submit value= > </form> form id pass forwardtag jsp 15 16 17 <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN <title>forwardtag.jsp</title> <% request.setcharacterencoding( utf-8 ); %> forward <jsp:forward page= forwardtag2.jsp /> 222
20..29 1: PM ` 223 ntech4 C9600 2400DPI 175LPI T 4.3 utf 8 forward forwardtag2 jsp forward 15 <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN <title>forwardtag2.jsp</title> forwardtag2.jsp.<hr> <%=request.getparameter( id ) %>.<br> <%=request.getparameter( pass ) %>. ID jsp PASSWORD asdfgh URL forwardtag2 jsp forward <jsp:param name= value= /> 223
20..29 1: PM ` 224 ntech4 C9600 2400DPI 175LPI T CHAPTER <jsp:forward page= > <jsp:param name= value= /> <jsp:param name= value= /> </jsp:forward> 4.3.3 <jsp:plugin > JSP JSP <jsp:plugin > 4.3.4 usebean (JavaBeans) <jsp:usebean id= class= /> <jsp:setproperty name= property= /> <jsp:getproperty name= property= /> usebean getproperty JSP setproperty getproperty getter (getxxx()) setter (setxxx()) usebean 4.4 JSP <%! %> <%= %> 224
20..29 1: PM ` 225 ntech4 C9600 2400DPI 175LPI T 4.4 4.4.1 (Declaration) JSP (parsing) Servlet JSP _jspservice() <%!. %> 15 16 17 18 19 20 21 22 <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN <title> </title> <%! String name = JSP ; int year = 20; public String getname() { return name; } %> : <%=name %><br> getname() : <%=getname() %><br> : <%=year %> <%! %> 2 getname() name (<%=name %>) getname() 225
20..29 1: PM ` 226 ntech4 C9600 2400DPI 175LPI T CHAPTER (<%=getname() %>) year (<%=year %>) 4.4.2 (Expression) <%= %> (;) out println() out println() + : <%=name %> : <%=getname() %> : <%= i+0= +(i+0)+ %> 4.5 (Scriptlet) JSP JSP JSP _jspservice() EL(Expression Language) JSTL HTML out println() HTML <%, if/for/while/switch %> 226
20..29 1: PM ` 227 ntech4 C9600 2400DPI 175LPI T 4.5 15 16 17 18 19 20 21 22 23 24 25 26 27 28 <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4. Transitional//EN <title> </title> <% // int number = 1; for (int i =0; i < 5; i++) { out.println(number + : ); out.println(getname() + <br> ); number++; } %> <%! // String name = ; public String getname() { return name; } %> scriptlet_jsp java _jspservice() JSP JSP JAVA JSP out println() HTML JSTL 227
20..29 1: PM ` 228 ntech4 C9600 2400DPI 175LPI T CHAPTER <% // int number = 1; for (int i =0; i < 5; i++) { //out.println(number + : ); //out.println(getname() + <br> ); //number++; //} %> <%=number %> : <%=getname() %><br> <% number++; } %> package org.apache.jsp; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; public final class scriptlet_jsp extends org.apache.jasper.runtime.httpjspbase implements org.apache.jasper.runtime.jspsourcedependent { // String name = ; public String getname() { return name; } private static final JspFactory _jspxfactory = JspFactory.getDefaultFactory(); private static java.util.list _jspx_dependants; private javax.el.expressionfactory _el_expressionfactory; private org.apache.annotationprocessor _jsp_annotationprocessor; public Object getdependants() { return _jspx_dependants; } public void _jspinit() { 228
20..29 1: PM ` 229 ntech4 C9600 2400DPI 175LPI T 4.5 _el_expressionfactory = _jspxfactory.getjspapplicationcontext(getservletconfig().getservletcontext()).getexpressionfactory(); _jsp_annotationprocessor = (org.apache.annotationprocessor) getservletconfig().getservletcontext().getattribute(org.apache.annotationprocessor.class.getname()); } public void _jspdestroy() { } public void _jspservice(httpservletrequest request, HttpServletResponse response) throws java.io.ioexception, ServletException { PageContext pagecontext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setcontenttype( text/html; charset=utf-8 ); pagecontext = _jspxfactory.getpagecontext(this, request, response, null, true, 8192, true); _jspx_page_context = pagecontext; application = pagecontext.getservletcontext(); config = pagecontext.getservletconfig(); session = pagecontext.getsession(); out = pagecontext.getout(); _jspx_out = out; out.write( \r\n ); out.write( <!DOCTYPE html PUBLIC \ -//W3C//DTD HTML 4. Transitional//EN\ \ http://www.w3.org/tr/html4/loose.dtd\ >\r\n ); out.write( \r\n ); out.write( \r\n ); out.write( <meta http-equiv=\ Content-Type\ content=\ text/html; charset=utf-8\ >\r\n ); out.write( <title> </title>\r\n ); out.write( \r\n ); out.write( \r\n ); // int number = 1; for (int i =0; i < 5; i++) { out.println(number + : ); out.println(getname() + <br> ); 229
20..29 1: PM ` 230 ntech4 C9600 2400DPI 175LPI T CHAPTER } number++; out.write( \r ); out.write( \n ); out.write( \r\n ); out.write( \r\n ); out.write( ); } catch (Throwable t) { if (!(t instanceof SkipPageException)){ out = _jspx_out; if (out!= null && out.getbuffersize()!= 0) try { out.clearbuffer(); } catch (java.io.ioexception e) {} if (_jspx_page_context!= null) _jspx_page_context.handlepageexception(t); } } finally { _jspxfactory.releasepagecontext(_jspx_page_context); } } } JSP JSP page include taglib include forward plugin usebean setproperty getproperty JSP/ JSP 230