JSP and JSTL Tutorials - Tutorial Addendum - JSP Tag Aspect Administration

arcadegamesios wordgamesios lifestyleappsios
 31 December 18:00   




(Continued from antecedent part...)



Tag Aspect Amount Announcement Archetype - AttObjectTag.java



The tag class:






* AttObjectTag.java


* Absorb (c) 2003 by Dr. Yang. All rights reserved.




package ;


import java.util.*;


import java.io.*;


import javax.servlet.jsp.*;


import javax.servlet.jsp.tagext.*;


import org.apache.taglibs.standard.lang.support.*;


public chic AttObjectTag extends TagSupport {


clandestine Cord booleanAtt = null;


clandestine Boolean booleanObject = null;


clandestine Cord stringAtt = null;


clandestine Cord stringObject = null;


clandestine Cord mapAtt = null;


clandestine Map mapObject = null;


accessible abandoned setBooleanAtt(String att) {


booleanAtt = att;


try {


booleanObject =


(Boolean) ExpressionEvaluatorManager.evaluate(


"booleanAtt", booleanAtt, java.lang.Boolean.class,


this, pageContext);


} bolt (JspException e) {








accessible abandoned setStringAtt(String att) {


stringAtt = att;


try {


stringObject =


(String) ExpressionEvaluatorManager.evaluate(


"stringAtt", stringAtt, java.lang.String.class,


this, pageContext);


} bolt (JspException e) {








accessible abandoned setMapAtt(String att) {


mapAtt = att;


try {


mapObject =


(Map) ExpressionEvaluatorManager.evaluate(


"mapAtt", mapAtt, java.util.Map.class,


this, pageContext);


} bolt (JspException e) {








accessible int doStartTag() {


JspWriter out = pageContext.getOut();


try {


out.println("booleanAtt = "+booleanAtt+"<br/>");


out.println("booleanObject = "+booleanObject+"<br/>");


out.println("stringAtt = "+stringAtt+"<br/>");


out.println("stringObject = "+stringObject+"<br/>");


out.println("mapAtt = "+mapAtt+"<br/>");


if (mapObject!=null) {


out.println("mapObject.size = "+mapObject.size()+"<br/>");


} abroad {


out.println("mapObject = null<br/>");




} bolt (IOException e) {






acknowledgment SKIP_BODY;








The TLD file:




<?xml version="1.0"?>


<!DOCTYPE taglib Accessible


"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"




<!-- HyTaglib.tld


Absorb (c) 2003 by Dr. Yang










<short-name> s Tag Library</short-name>









































The JSP page:




<?xml version="1.0"?>


<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"




xmlns:hy="urn:jsptld:/WEB-INF/tlds/HyTaglib.tld" version="1.2">


<!-- AttObjectTagTest.jsp


Absorb (c) 2003 by Dr. Yang




<jsp:directive.page contentType="text/html"/>




<p>Regular Strings:</p>


<hy:attObject booleanAtt="true" stringAtt="Hello world!"/>




<hy:attObject booleanAtt="${false}" stringAtt="${ Yang }"/>




<hy:attObject booleanAtt="${1==1}"












The output:




Regular Strings:


booleanAtt = true


booleanObject = true


stringAtt = Accost world!


stringObject = Accost world!


mapAtt = null


mapObject = null




booleanAtt = ${false}


booleanObject = false


stringAtt = ${ Yang }


stringObject = Yang


mapAtt = null


mapObject = null




booleanAtt = ${1==1}


booleanObject = true


stringAtt = ${pageContext.request.method}


stringObject = GET


mapAtt = ${cookie}


mapObject.size = 0




Note that:



  • The JSTL announcement appraisal apparatus is a changeless method, evaluate(), in


    ExpressionEvaluationManager class, in org.apache.taglibs.standard.lang.support package.



  • The announcement rules are identical to those declared in JSTL, because we


    are using the aforementioned appraisal tool.



  • If you bang "refresh" button on the browser, the mapObject.size will be 1,


    because the affair id is stored in the cookie map.







Tags: system, world, class, attribute, support, catch, notes, public, string, tutorial, tutorials

 booleanatt, println, attribute, string, stringatt, class, mapatt, version, mapobject, private, public, required, import, stringobject, pagecontext, system, tostring, catch, booleanobject, evaluate, false<, xmlns, world, attobject, boolean, expression, expressionevaluatormanager, jspexception, copyright, attobjecttag, taglib, , attribute <, < attribute, null private, name <, < jsp, err println, < name, private string, system err, < tag, < body, < required, attobject booleanatt, html <, required <, false< required, required false<, http java, string att, att try, public void, tag class, tag attribute, expressionevaluatormanager evaluate, class this, java sun, jsp tag, mapobject size, catch jspexception, sun com, null private string, class this pagecontext, < required false<, required false< required, standard lang support, taglibs standard lang, apache taglibs standard, tutorials tutorial notes, tag attribute handling, import javax servlet, org apache taglibs, jstl tutorials tutorial,

Share JSP and JSTL Tutorials - Tutorial Addendum - JSP Tag Aspect Administration:
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Article In : Computers & Technology  -  jsp