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

arcadegamesios wordgamesios lifestyleappsios
 31 December 18:00   

    



    



    

(Continued from antecedent part...)

    



    

The JSP file:

    

 

    

<?xml version="1.0"?>

    

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

    

xmlns:c="http://java.sun.com/jstl/core"

    

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

    

<!-- AttValueTagTest.jsp

    

Absorb (c) 2003 by Dr. Yang

    

-->

    

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

    

<html><body>

    

<hy:attValue longObject="1" longValue="2"

    

doubleObject="1.1" doubleValue="2.2"

    

booleanObject="true" booleanValue="false"

    

stringObject="Hello world!"/>

    

</body></html>

    

</jsp:root>

    



    



    

The output:

    

 

    

longValue = 2

    

longObject = 1

    

doubleValue = 2.2

    

doubleObject = 1.1

    

booleanValue = false

    

booleanObject = true

    

stringObject = Accost world

    



    



    

The Servlet chic produced by Bobcat server:

    

 

    

...

    

clandestine boolean _jspx_meth_hy_attValue_0(

    

javax.servlet.jsp.PageContext pageContext)

    

throws Throwable {

    

JspWriter out = pageContext.getOut();

    

/* ---- hy:attValue ---- */

    

.AttValueTag _jspx_th_hy_attValue_0 = (.AttValueTag)

    

_jspx_tagPool_hy_attValue_stringObject_longValue_longObject...

    

_jspx_th_hy_attValue_0.setPageContext(pageContext);

    

_jspx_th_hy_attValue_0.setParent(null);

    

_jspx_th_hy_attValue_0.setLongObject(new Long(1l));

    

_jspx_th_hy_attValue_0.setLongValue(2l);

    

_jspx_th_hy_attValue_0.setDoubleObject(new Double(1.1));

    

_jspx_th_hy_attValue_0.setDoubleValue(2.2);

    

_jspx_th_hy_attValue_0.setBooleanObject(new Boolean(true));

    

_jspx_th_hy_attValue_0.setBooleanValue(false);

    

_jspx_th_hy_attValue_0.setStringObject("Hello world!");

    

int _jspx_eval_hy_attValue_0 = _jspx_th_hy_attValue_0.doStartTag();

    

if (_jspx_th_hy_attValue_0.doEndTag() ==

    

javax.servlet.jsp.tagext.Tag.SKIP_PAGE)

    

acknowledgment true;

    

_jspx_tagPool_hy_attValue_stringObject_longValue_longObject...

    

acknowledgment false;

    

}

    

...

    



    



    

I alone affected the adjustment that interacts with the tag chic out of the Servlet

    

class here. Agenda that:

    



        

  • The setter methods for the archaic data types are alleged with aspect values

        

    directly, except that "l" is added to the end of the value, like "1l".

        



  •     

  • The setter methods for the adhesive classes of the archaic data types are

        

    called with new altar instantiated with the aspect values.

        



  •     

  • How can Bobcat server amount out the chic blazon of the setter adjustment parameter?

        

    Could anyone advice me here?

        



  •     



    



    



    

Tag Aspect Amount Expression

    



    

In the antecedent sections, I alone talked about how to ascertain an aspect in a custom

    

tag, how aspect ethics are anesthetized to the tag class, and how aspect values

    

are adapted to actual data blazon appropriate by the tag class. Now let s attending at

    

the achievability of entering expressions as aspect ethics in a custom tag, similar

    

to JSTL tags.

    



    

Based on my readings on the Internet, announcement accent is not accurate directly

    

in custom tags in JSP 1.2. About there are two approaches to use expressions indirectly

    

in custom tags.

    



    

1. Using Java announcement elements as aspect values. You charge to ascertain the

    

attribute in the TLD book with <rtexprvalue>true</rtexprvalue>, then enter

    

the aspect amount with the afterward format:

    

 

    

<hy:tag att="<%=java_expression%>"/>

    



    



    

2. Using JSTL expressions and appraise them central tag class. You can access

    

a JSTL announcement in an aspect value, accustomed it by the setter adjustment

    

as a string, then appraise it to the admiration data blazon using the announcement

    

evaluation apparatus action by the JSTL.

    



    

The first access requires the JSP page to be accounting in a non-XML format. And

    

I don t like that format. So I am not traveling to try that.

    



    

The additional access seems to be absorbing and powerful. You can use it to canyon

    

an item of any chic as an aspect amount to the tag class. See the archetype

    

bellow.

    

(Continued on next part...)

    



    

 


Tags: types, class, custom, value, method, attribute, format, values, notes, false, tutorial, tutorials

 attvalue, attribute, class, value, pagecontext, setter, values, servlet, longvalue, expression, format, expressions, custom, method, false, stringobject, xmlns, longobject, , tag class, attribute values, attribute value, html <, < jsp, tag attribute, stringobject longvalue longobject, primitive data types, attvalue stringobject longvalue, tag attribute handling, tutorials tutorial notes, 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 ...

Permalink
Article In : Computers & Technology  -  jsp