chapter5.doc

Similar documents
TP_jsp7.PDF

I T C o t e n s P r o v i d e r h t t p : / / w w w. h a n b i t b o o k. c o. k r

04장

chapter3.doc

chapter6.doc

rmi_박준용_final.PDF

PowerPoint 프레젠테이션

12-file.key

KYO_SCCD.PDF

JavaGeneralProgramming.PDF

chapter1,2.doc

02 C h a p t e r Java

PowerPoint 프레젠테이션

14-Servlet

Analytics > Log & Crash Search > Unity ios SDK [Deprecated] Log & Crash Unity ios SDK. TOAST SDK. Log & Crash Unity SDK Log & Crash Search. Log & Cras

PowerPoint 프레젠테이션

Data Provisioning Services for mobile clients

J2EE Concepts

목차 1. SDK Package 구성 2. 설치 3. API 소스설명 CTI 기능 luxsys_killsession Pop창에서웹링크로들어온세샨키를없세버리는방법 / 루틴 luxsys_click2dial 전화통화방식 : (Click-to-Dial 하고 Power/Mult

JMF2_심빈구.PDF

MasoJava4_Dongbin.PDF

신림프로그래머_클린코드.key

ilist.add(new Integer(1))과 같이 사용하지 않고 ilist.add(1)과 같이 사용한 것은 자바 5.0에 추가된 기본 자료형과 해당 객체 자료 형과의 오토박싱/언박싱 기능을 사용한 것으로 오토박싱이란 자바 컴파일러가 객체를 요구하는 곳에 기본 자료형

비긴쿡-자바 00앞부속

Interstage5 SOAP서비스 설정 가이드

Intro to Servlet, EJB, JSP, WS

09-interface.key

PowerPoint 프레젠테이션

자바GUI실전프로그래밍2_장대원.PDF

Java

교육2 ? 그림

03장

JMF3_심빈구.PDF

PowerPoint Presentation

Microsoft PowerPoint - 7강.pptx

자바-11장N'1-502

No Slide Title

Dialog Box 실행파일을 Web에 포함시키는 방법

혼자서일을다하는 JSP. 이젠일을 Servlet 과나눠서한다. JSP와서블릿의표현적인차이 - JSP는 <html> 내에서자바를사용할수있는수단을제공한다. - 서블릿은자바내에서 <html> 을작성할수있는수단을제공한다. - JSP나서블릿으로만웹페이지를작성하면자바와다양한코드가

Chap12

뇌를 자극하는 JSP & Servlet 슬라이드

API STORE 키발급및 API 사용가이드 Document Information 문서명 : API STORE 언어별 Client 사용가이드작성자 : 작성일 : 업무영역 : 버전 : 1 st Draft. 서브시스템 : 문서번호 : 단계 : Docum


11 템플릿적용 - Java Program Performance Tuning (김명호기술이사)

DocsPin_Korean.pages

07 자바의 다양한 클래스.key

Ext JS À¥¾ÖÇø®ÄÉÀ̼ǰ³¹ß-³¹Àå.PDF

목차 JEUS EJB Session Bean가이드 stateful session bean stateful sample 가이드 sample source 결과확인 http session에

mytalk

ch09

05-class.key

fundamentalOfCommandPattern_calmglow_pattern_jstorm_1.0_f…

제8장 자바 GUI 프로그래밍 II

untitled

Microsoft PowerPoint - 04-UDP Programming.ppt

01-OOPConcepts(2).PDF

Java XPath API (한글)

본 발명은 중공코어 프리캐스트 슬래브 및 그 시공방법에 관한 것으로, 자세하게는 중공코어로 형성된 프리캐스트 슬래브 에 온돌을 일체로 구성한 슬래브 구조 및 그 시공방법에 관한 것이다. 이를 위한 온돌 일체형 중공코어 프리캐스트 슬래브는, 공장에서 제작되는 중공코어 프

2파트-07

3ÆÄÆ®-14

rosaec_workshop_talk

Connection 8 22 UniSQLConnection / / 9 3 UniSQL OID SET

C++-¿Ïº®Çؼ³10Àå

03장.스택.key

Mobile Service > IAP > Android SDK [ ] IAP SDK TOAST SDK. IAP SDK. Android Studio IDE Android SDK Version (API Level 10). Name Reference V

Apache2 + Tomcat 5 + JK2 를 사용한 로드밸런싱과 세션 복제 클러스터링 사이트 구축

<param-value> 파라미터의값 </param-value> </init-param> </servlet> <servlet-mapping> <url-pattern>/ 매핑문자열 </url-pattern> </servlet-mapping> - 위의예에서 ServletC

Microsoft PowerPoint - web-part03-ch19-node.js기본.pptx

Modern Javascript

4. #include <stdio.h> #include <stdlib.h> int main() { functiona(); } void functiona() { printf("hihi\n"); } warning: conflicting types for functiona

PHP & ASP

파일로입출력하기II - 파일출력클래스중에는데이터를일정한형태로출력하는기능을가지고있다. - PrintWriter와 PrintStream을사용해서원하는형태로출력할수있다. - PrintStream은구버전으로가능하면 PrintWriter 클래스를사용한다. PrintWriter

<4D F736F F F696E74202D20B5A5C0CCC5CDBAA3C0CCBDBA5F3130C1D6C2F75F31C2F7BDC32E >

Microsoft PowerPoint - 03-TCP Programming.ppt

13ÀåÃß°¡ºÐ

C H A P T E R 2

Javascript.pages

Eclipse 와 Firefox 를이용한 Javascript 개발 발표자 : 문경대 11 년 10 월 26 일수요일

* Factory class for query and DML clause creation * tiwe * */ public class JPAQueryFactory implements JPQLQueryFactory private f

Microsoft PowerPoint - aj-lecture9.ppt [호환 모드]

NATE CP 컨텐츠 개발규격서_V4.4_1.doc

기술문서 작성 XXE Attacks 작성자 : 인천대학교 OneScore 김영성 I. 소개 2 II. 본문 2 가. XML external entities 2 나. XXE Attack 3 다. 점검방법 3 라.

untitled

Cluster management software

Microsoft PowerPoint - Supplement-03-TCP Programming.ppt [호환 모드]

초보자를 위한 자바 2 21일 완성 - 최신개정판

nTOP CP 컨텐츠 개발규격서_V4.1_.doc

Java ...

서블릿의라이프사이클 뇌를자극하는 JSP & Servlet

歯Writing_Enterprise_Applications_2_JunoYoon.PDF

PowerPoint 프레젠테이션

어댑터뷰


3장

chap 5: Trees

03-JAVA Syntax(2).PDF

PowerPoint 프레젠테이션

2장 변수와 프로시저 작성하기

Chap7.PDF

Contents Contents 2 1 Abstract 3 2 Infer Checkers Eradicate Infer....

Transcription:

Chapter 5 Custom Tag Library javabeans jsp, Bean jsp content scripting jsp ( ) xxx, Custom tag( ) 1 Tag Handler Class ( ) 2 Tag Library Descriptor File ( ) 3 taglib (JSP ) Tag Handler Class ( ) Class, JSP, JSP javaxservletjsptagexttag (implements), javaxservletjsptagexttagsupport javaxservletjsptagextbodytagsupport (extends) TagSupport, BodyTagSupport Tag Tag Hello Jsp List 51Hello jsp http://wwwjava2xmlcom

List 51 CustomTagExjava package comboolpaejsp; import javaxservletjsp*; import javaxservletjsptagext*; import javaio*; public class CustomTagEx extends TagSupport{ public int dostarttag(){ try{ JspWriter out = pagecontextgetout(); outprint(" "); catch(ioexception e){ Systemoutprintln("Error : "+e); return SKIP_BODY; List 51TagSupport TagSupport BodyTagSupport javaxservletjsptagext import Tag javaxservletjsp javaio import JspWriter javaxservletjsp dostarttag <tag attribute= value >body</tag> attribute, body dostarttag, JspWriter JSP out javaioprintwriter (?), PrintWriter JspWriter pagecontext getout() pagecontext request, response, sessionjsp getrequest(), getresponse(), getsession() JspWriterprint IOException try~catch http://wwwjava2xmlcom

dostarttag JspException dostarttag public int dostarttag() throws JspException{ try{ JspWriter out = pagecontextgetout(); outprint(" "); catch(ioexception e){ throw new JspTagException("Error : "+egetmessage()); return SKIP_BODY; SKIP_BODY SKIP_BODY SKIP_BODY SKIP_BODY? Tag 4 SKIP_BODY EVAL_BODY_INCLUDE, SKIP_PAGE, EVAL_PAGE EVAL_BODY_INCLUDE SKIP_BODY SKIP_PAGEEVAL_PAGEdoEndTag doendtag, tag ( ) doendtag SKIP_PAGE,, EVAL_PAGE SKIP_BODY EVAL_BODY_INCLUDE dostarttag dostarttag SKIP_PAGE EVAL_PAGE doendtag doendtag BodyTagSupport EVAL_BODY_TAG doafterbody, http://wwwjava2xmlcom

jsp WEB-INF/classes Tag Library Descriptor( ) List 52 List 52 taglibexampletld <?xml version="10" encoding="iso-8859-1"?> <!DOCTYPE taglib PUBLIC "-//Sun MicroSystems, Inc //DTD JSP Tag Library 11//EN" "http://javasuncom/j2ee/dtds/web-jsptaglibrary_1_1dtd"> <taglib> <tlibversion>10</tlibversion> <jspversion>11</jspversion> <shortname>jspace</shortname> <uri/> <info> JavaServer Pages tag library Example </info> <tag> <name>test</name> <tagclass>comboolpaejspcustomtagex</tagclass> <info>simple example</info> <bodycontent>empty</bodycontent> </tag> </taglib> List 52 xml xml xml Html,! xml <?xml version= 10?> encoding DTD(Sun) DTD List 52 xml <taglib> Html <html> <taglib> <tag> <tlibversion> 10 http://wwwjava2xmlcom

<jspversion>jsp 11 11 <shortname> jsp (prefix) jsp taglib taglib? <%@ taglib uri= taglibraryuri prefix= tagprefix %> <tag> <tlibversion> <shortname> <uri> uri, <info> <tag> List 52 <name>taglib <name>test</name> test, taglib prefix= jspace, jsp <jspace:test> xml <jspace:test/> <tagclass> test <tagclass> List 52 <tagclass>comboolpaejspcustomtagex</tagclass> <info> <bodycontent> EMPTY, JSP, TAGDEPEDENT EMPTY, JSPJSP TAGDEPENT JSP Page jsp? taglib List 53 List 53 TagExjsp <%@ page contenttype="text/html;charset=euc-kr" %> <HTML> <HEAD> http://wwwjava2xmlcom

<TITLE> </TITLE> </HEAD> <BODY> <CENTER> <H1> </H1><br><br> <%@ taglib uri="web-inf/tlds/taglibexampletld" prefix="jspace" %> <font size=5 color=black face=" "><jspace:test/></font><br> <font size=3 color=blue face=" "><jspace:test/></font><br> <font size=2 color=orange face=" "><jspace:test/></font><br> </CENTER> </BODY> </HTML> List 53 WEB-INF/tlds/taglibExampletld, prefixjspace TLD( ) WEB-INF tlds, Custom Tag <jspace:test attribute01= value01 attribute02= value02 /> http://wwwjava2xmlcom

setattribute() Attribute attribute01, attribute02 setxxx (?) <jsp:setproperty name property value /> Property Xxx setattribute() TLD( TLD ) private int size; public int dostarttag(){ outprint("<font size='"+size+"'> "); public void setsize(int size){ thissize=size; size int setsize, TLD <attribute> <tag> <tag> <attribute> <name>size</name> <required>false</required> <rtexprvalue>false</rtexprvalue> </attribute>, <name> <required> true false <rtexprvalue> (expression) true false false <jspace:test size= <%=requestgetprarameter( size )%> /> <jspace:test size= 3 /> (?) http://wwwjava2xmlcom

List 54 CustomTagExjava package comboolpaejsp; import javaxservletjsp*; import javaxservletjsptagext*; import javaio*; public class CustomTagEx extends TagSupport{ private int size; public int dostarttag(){ try{ JspWriter out = pagecontextgetout(); outprint("<font size='"+size+"'> "); catch(ioexception e){ Systemoutprintln("Error : "+e); return SKIP_BODY; public void setsize(int size){ thissize=size; List 55 taglibexampletld <?xml version="10" encoding="iso-8859-1"?> <!DOCTYPE taglib PUBLIC "-//Sun MicroSystems, Inc //DTD JSP Tag Library 11//EN" "http://javasuncom/j2ee/dtds/web-jsptaglibrary_1_1dtd"> <taglib> <tlibversion>10</tlibversion> <jspversion>11</jspversion> <shortname>jspace</shortname> <urn/> <info> JavaServer Pages tag library Example </info> <tag> <name>test</name> <tagclass>comboolpaejspcustomtagex</tagclass> <info>simple example</info> <bodycontent>empty</bodycontent> <attribute> <name>size</name> <required>false</required> <rtexprvalue>false</rtexprvalue> </attribute> http://wwwjava2xmlcom

</tag> </taglib> jsp? jsp font List 56 tagexjsp <HTML> <HEAD> <TITLE> </TITLE> </HEAD> <BODY> <CENTER> <H1> </H1><br><br> <%@ taglib uri="web-inf/tlds/taglibexampletld" prefix="jspace" %> <jspace:test size="5" /></font><br> <jspace:test size='3' /></font><br> <jspace:test size='2'/></font><br> </CENTER> </BODY> </HTML> font size attribute (" "), (' ') attribute a, setattribute() A http://wwwjava2xmlcom

Custom Tag <jspace:test /> <jspace:test> </jspace:test>, dostarttagskip_body EVAL_BODY_INCLUDE EVAL_BODY_INCLUDE, doendtag() dostarttag() doendtag EVAL_PAGE SKIP_PAGE (scripting elements), (expression), (action) dostarttag fontsize face( ) doendtag font font dostarttag EVAL_BODY_INCLUDE List 57 List 57 CustomTagExjava http://wwwjava2xmlcom

package comboolpaejsp; import javaxservletjsp*; import javaxservletjsptagext*; import javaio*; public class CustomTagEx extends TagSupport{ private int size; private String face; public int dostarttag(){ try{ JspWriter out = pagecontextgetout(); outprint("<font size='"+size+"' face='"+face+"'>"); catch(ioexception e){ Systemoutprintln("Error : "+e); return EVAL_BODY_INCLUDE; public int doendtag(){ try{ JspWriter out = pagecontextgetout(); outprint("</font>"); catch(ioexception e){ Systemoutprintln("Error : "+e); return EVAL_PAGE; public void setsize(int size){ thissize=size; public void setface(string face){ thisface = face; TLD face <attribute> <tag> <bodycontent> JSP JSP JSP List 58 taglibexampletld <?xml version="10" encoding="iso-8859-1"?> <!DOCTYPE taglib PUBLIC "-//Sun MicroSystems, Inc //DTD JSP Tag Library 11//EN" "http://javasuncom/j2ee/dtds/web-jsptaglibrary_1_1dtd"> http://wwwjava2xmlcom

<taglib> <tlibversion>10</tlibversion> <jspversion>11</jspversion> <shortname>jspace</shortname> <urn/> <info> JavaServer Pages tag library Example </info> <tag> <name>test</name> <tagclass>comboolpaejspcustomtagex</tagclass> <info>simple example</info> <bodycontent>jsp</bodycontent> <attribute> <name>size</name> <required>false</required> <rtexprvalue>false</rtexprvalue> </attribute> <attribute> <name>face</name> <required>false</required> <rtexprvalue>false</rtexprvalue> </attribute> </tag> </taglib> List 59 tagexjsp <%@ page contenttype="text/html;charset=euc-kr" %> <style> BODY {font-family:tahoma; font-size:20pt </style> <HTML> <HEAD> <TITLE> </TITLE> </HEAD> <BODY> <CENTER> <H1> </H1><br><br> <%@ taglib uri="web-inf/tlds/taglibexampletld" prefix="jspace" %> <jspace:test size="6" face="comic sans MS">This font is Comic sans MS</jspace:test><br> <jspace:test size='4' face="verdana">bluenote Custom Tag is Verdana font Style </jspace:test><br> <jspace:test size='2' face="system">system font style is so strong</jspace:test><br> <hr> This font is pre-defined in style Tag </CENTER> </BODY> http://wwwjava2xmlcom

</HTML> BODY doendtag </font> font style (attribute)? size face size=0, face=null http://wwwjava2xmlcom

List 510 OptionTagjava package comboolpaejsp; import javaxservletjsp*; import javaxservletjsptagext*; import javaxservlet*; import javaio*; public class OptionTag extends TagSupport{ public int dostarttag(){ ServletRequest request = pagecontextgetrequest(); String option = requestgetparameter("option"); if("yes"equalsignorecase(option)){ return EVAL_BODY_INCLUDE; else{ return SKIP_BODY; option yes, pagecontext jsp ( jsp, jsp API ) getrequest() ServletRequst request List 511 taglibexampletld <!--------- ------ <taglib> <! ------- ------ <tag> <name>option</name> <tagclass>comboolpaejspoptiontag</tagclass> <info>option tag example</info> <bodycontent>jsp</bodycontent> </tag> </taglib> List 511 taglibexampletld <tag> </tag> http://wwwjava2xmlcom

List 512 optiontagjsp <%@ page import="javautilenumeration" contenttype="text/html;charset=euc- KR" %> <HTML> <HEAD> <TITLE> Option Tag Example </TITLE> </HEAD> <BODY> <center> <h1> Option Tag Example </h1><br> option parameter yes <br> yes <br><br> <%@ taglib uri="web-inf/tlds/taglibexampletld" prefix="jspace" %> <jspace:option> <% Enumeration e = requestgetheadernames(); while(ehasmoreelements()){ String headername = (String)enextElement(); %> Header Name : <%=headername%> : <%= requestgetheader(headername) %><br> <% %> </jspace:option> </BODY> </HTML> List 512 Http Request requestgetheadernames() Enumeration while Header EnumerationObject ( String ) requestgetheader(),,, option yes URL get [ ] http://wwwjava2xmlcom

[ yes ] http://wwwjava2xmlcom

Body BodyTagSupport TagSupport dostarttag doendtag Tag (implements) TagSupport Tag BodyTagSupport TagSupport BodyTag BodyTagSupport Tag BodyTagSupport, doafterbody : SKIP_BODY EVAL_BODY_TAG, getbodycontent :, BodyContent JspWriter getpreviousout : JspWriter JspWriter JspWriter enclosing writer TagSupport dostarttag pagecontextgetout JspWriter getprevioustout JspWriter dostarttagdoendtag JspWriter BodyContent JspWriter JspWriter BodyContentgetEnclosingWirter, getpreivousout, BodyContentgetEnclosingWriter JspWriter getstring : BodyContent String http://wwwjava2xmlcom

Html < > < > List 512 SourceViewjava package comboolpaejsp; public class SourceView{ public static String filter(string source){ StringBuffer sourcefilter = new StringBuffer(sourcelength()); char c; for(int i=0;i<sourcelength();i++){ c = sourcecharat(i); if(c=='<'){ sourcefilterappend("<"); else if(c=='>'){ sourcefilterappend(">"); else{ sourcefilterappend(c); return sourcefiltertostring(); StringBuffer,, String charat(index) append StringBuffer List 513 SourceTagjava package comboolpaejsp; import javaxservletjsp*; import javaxservletjsptagext*; import javaio*; public class SourceTag extends BodyTagSupport{ public int doafterbody(){ BodyContent body = getbodycontent(); String filteredbody = SourceViewfilter(bodygetString()); try{ http://wwwjava2xmlcom

JspWriter out = getpreviousout(); outprint(filteredbody); catch(ioexception e){ Systemoutprintln("Error : " +e); return SKIP_BODY; BodyContent getstring String List 512 SourceView filter <, > < > getpreviousout JspWriter SKIP_BODY (?)TLD taglibexampletld List 514 taglibexampletld <tag> <name>filter</name> <tagclass>comboolpaejspsourcetag</tagclass> <info>source code view Tag: Non HTML code</info> <bodycontent>jsp</bodycontent> </tag> JSP List 515 SourceViewjsp <HTML> <HEAD> <TITLE> Source code Filter </TITLE> <style> BODY {font-family: ; font-size:12pt TABLE, TR, TD {font-family: ; font-size:18pt </style> </HEAD> <BODY> <center> <h1>source View Example </h1> <%@ taglib uri="web-inf/tlds/taglibexampletld" prefix="jspace" %> <jspace:filter> <table><tr><td> TD </td></tr></table> </jspace:filter> http://wwwjava2xmlcom

<hr> <table><tr><td> TD </td></tr></table> </BODY> </HTML>, HTML Style style [SourceViewjsp] doafterbody EVAL_BODY_TAG? SKIP_BODY! List 516 LoopTagjava package comboolpaejsp; http://wwwjava2xmlcom

import javaxservletjsp*; import javaxservletjsptagext*; import javaio*; public class LoopTag extends BodyTagSupport{ private int repeats; public void setrepeats(int repeats){ thisrepeats = repeats; public int doafterbody(){ if(repeats-- >= 1){ BodyContent body = getbodycontent(); try{ JspWriter out = getpreviousout(); outprintln(bodygetstring()); bodyclearbody(); catch(ioexception e){ Systemoutprintln("Error : "+e); return EVAL_BODY_TAG; else{ return SKIP_BODY; List 516 0 doafterbody EVAL_BODY_TAG? TLD List 517 taglibexampletld <tag> <name>loop</name> <tagclass>comboolpaejsplooptag</tagclass> <info>loop tag body</info> <bodycontent>jsp</bodycontent> </tag> <attribute> <name>repeats</name> <required>false</required> <rtexprvalue>true</rtexprvalue> </attribute> <rtexprvalue> true http://wwwjava2xmlcom

jsp, jsp List 518 LoopTagjsp <HTML> <HEAD> <TITLE> New Document </TITLE> </HEAD> <BODY> <center> <%@ taglib uri="web-inf/tlds/taglibexampletld" prefix="jspace" %> <jspace:loop repeats="10"> i love you~<br> </jspace:loop> </BODY> </HTML> ~10 JSP? http://wwwjava2xmlcom

List 519 inlooptagjava package comboolpaejsp; import javaxservletjsp*; import javaxservletjsptagext*; import javaio*; public class InLoopTag extends TagSupport{ public int dostarttag(){ double i = Mathrandom(); try{ JspWriter out = pagecontextgetout(); outprint(i); catch(ioexception e){ Systemoutprintln("Error : "+e); return SKIP_BODY; Mathrandom TLD List 520 taglibexampletld <tag> <name>inloop</name> <tagclass>comboolpaejspinlooptag</tagclass> <info>will be repeated in Loop Tag</info> <bodycontent>jsp</bodycontent> </tag> JSP, LoopTag repeats <rtexprvalue> true LoopTag, setrepeats http://wwwjava2xmlcom

List 521 LoopTagsetRepeats public void setrepeats(string repeats){ try{ thisrepeats = IntegerparseInt(repeats); catch(numberformatexception e){ thisrepeats = 1; requestgetparameter String NumberFormatException, LoopTagjsp List 522 LoopTagjsp <HTML> <HEAD> <TITLE> New Document </TITLE> </HEAD> <BODY> <center> <h1>loop Tag Example</h1> <%@ taglib uri="web-inf/tlds/taglibexampletld" prefix="jspace" %> <jspace:loop repeats='<%=requestgetparameter("repeats")%>'> <jspace:inloop/><br> </jspace:loop> </BODY> </HTML> 5, 10 repeats [5 LoopTagjsp] http://wwwjava2xmlcom

[10 LoopTagjsp] http://wwwjava2xmlcom

JSP ( )? ~ API, findancestorwithclass API public static final Tag findancestorwithclass(tag tag, javalangclass cl) final, Class Class class JspTagException, <prefix:if> <prefix:condition>true false</prefix:condition> <prefix:then> if condition is true then process something </prefix:then> <prefix:else> if condition is false then process something </prefix:else> </prefix:if> http://wwwjava2xmlcom

if(condition){ else{ List 523 IfTagjava package comboolpaejsp; import javaxservletjsp*; import javaxservletjsptagext*; import javaio*; public class IfTag extends TagSupport{ private boolean condition; private boolean hascondition = false; public void setcondition(boolean condition){ thiscondition = condition; hascondition = true; public boolean getcondition(){ return condition; public void sethascondition(boolean hascondition){ thishascondition = hascondition; public boolean gethascondition(){ return hascondition; http://wwwjava2xmlcom

public int dostarttag(){ return EVAL_BODY_INCLUDE; condition hascondition conditiontrue false hascondition conditionif hasconditionfalse ( false ) condition sethascondition hascondition true List 524 IfConditionTagjava package comboolpaejsp; import javaxservletjsp*; import javaxservletjsptagext*; import javaio*; public class IfConditionTag extends BodyTagSupport{ public int dostartag() throws JspException{ IfTag parent = (IfTag)findAncestorWithClass(this, IfTagclass); if(parent == null){ throw new JspTagException("ConditionTag Error"); return EVAL_BODY_TAG; public int doafterbody(){ IfTag parent = (IfTag)findAncestorWithClass(this, IfTagclass); BodyContent body = getbodycontent(); String bodystring = bodygetstring(); if("true"equals(bodystringtrim())){ parentsetcondition(true); http://wwwjava2xmlcom

else{ parentsetcondition(false); return SKIP_BODY; IfConditionTag dostarttag findancestorwithclass (IfTag) trueiftag condtion true false equals equalsignorecase SKIP_BODY IfThenTag List 525 IfThenTagjava package comboolpaejsp; import javaxservletjsp*; import javaxservletjsptagext*; import javaio*; public class IfThenTag extends BodyTagSupport{ public int dostarttag() throws JspTagException{ IfTag parent = (IfTag)findAncestorWithClass(this, IfTagclass); if(parent == null){ throw new JspTagException("Error in IfThen Tag : parent Tag is null"); else if(!parentgethascondition()){ throw new JspTagException("Error in IfThen Tag: IfTag's hascondition value is false"); return EVAL_BODY_TAG; public int doafterbody(){ IfTag parent = (IfTag)findAncestorWithClass(this, IfTagclass); http://wwwjava2xmlcom

if(parentgetcondition()){ try{ BodyContent body = getbodycontent(); JspWriter out = getpreviousout(); outprint(bodygetstring()); catch(ioexception e){ Systemoutprintln("Error in IfThen Tag : "+e); return SKIP_BODY; IfThen dostarttag (IfTag) hasconditionfalse IfCondition Condition hasconditiontrue EVAL_BODY_TAG doafterbody doafterbody IfTag conditiontrue true IfThen conditiontrue true List 526 IfElseTagjava package comboolpaejsp; import javaxservletjsp*; import javaxservletjsptagext*; import javaio*; public class IfElseTag extends BodyTagSupport{ public int dostarttag() throws JspTagException{ IfTag parent = (IfTag)findAncestorWithClass(this, IfTagclass); if(parent == null){ throw new JspTagException("Error in IfElseTag : parent Tag is null"); else if(parentgethascondition()){ throw new JspTagException("Error in IfElseTag : IfTag's hascondition http://wwwjava2xmlcom

value is false"); return EVAL_BODY_TAG; public int doafterbody(){ IfTag parent = (IfTag)findAncestorWithClass(this, IfTagclass); if(!parentgetcondition()){ try{ BodyContent body = getbodycontent(); JspWriter out = getpreviousout(); outprint(bodygetstring()); catch(ioexception e){ Systemoutprintln("Error in IfElseTag : "+e); return SKIP_BODY; IfElseTag IfThen dostarttagifthen doafterbody condition false 4 ~ TLD List 527taglibExampletld List 527 taglibexampletld <tag> <name>if</name> <tagclass>comboolpaejspiftag</tagclass> <info>if Tag</info> <bodycontent>jsp</bodycontent> </tag> <tag> http://wwwjava2xmlcom

<name>condition</name> <tagclass>comboolpaejspifconditiontag</tagclass> <info>ifcondition Tag</info> <bodycontent>jsp</bodycontent> </tag> <tag> <name>then</name> <tagclass>comboolpaejspifthentag</tagclass> <info>ifthen Tag</info> <bodycontent>jsp</bodycontent> </tag> <tag> <name>else</name> <tagclass>comboolpaejspifelsetag</tagclass> <info>ifelse Tag</info> <bodycontent>jsp</bodycontent> </tag> TLD JSP JSP condition condition, loop Mathrandom() 05, List 528 IfTagExamplejsp <HTML> <HEAD> <TITLE> </TITLE> <style> BODY {font-size:15pt </style> </HEAD> <BODY> <center> <h1> Example </h1> http://wwwjava2xmlcom

<%@ taglib uri="web-inf/tlds/taglibexampletld" prefix="jspace" %> <jspace:if> <jspace:condition><%=requestgetparameter("condition")%></jspace:conditi on> <jspace:then>condition is true</jspace:then> <jspace:else>condition is false</jspace:else> </jspace:if> <hr> <jspace:loop repeats='10'> <jspace:if> <jspace:condition><%=mathrandom() > 05%></jspace:condition> <jspace:then>the number is greater than 05<br></jspace:then> <jspace:else>the number is smaller than 05<br></jspace:else> </jspace:if> </jspace:loop> </BODY> </HTML> http://wwwjava2xmlcom

http://wwwjava2xmlcom chapter JSP? ASPPHP JSP,

JSP JSP MVC, MVC MVC (MVC SmallTalk GUI ) Thinking in Patterns with Java(Bruce Eckel ) J2EE MVC Sun http://javasuncom/j2ee/blueprints/design_patterns/mvc/indexhtml EJB 2 chapter JDBC http://wwwjava2xmlcom