You are here: Articles > Computers & Technology > jsp

 See more articles about "jsp "

JSP and JSTL Tutorials - Tutorial Addendum - JSP Custom Tag



 31 December 18:00   

    



    



    

(Continued from antecedent part...)

    



    

3. Autograph the tag library descriptor (tld) file. Now, I charge to ascertain a tag in a tag library

    

descriptor book to use the tag class. Actuality is my first tld file, HyTaglib.tld:

    

 

    

<?xml version="1.0"?>

    

<!DOCTYPE taglib Accessible

    

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

    

"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_2.dtd">

    

<!-- HyTaglib.tld

    

Absorb (c) 2003 by Dr. Yang

    

-->

    

<taglib>

    

<tlib-version>1</tlib-version>

    

<jsp-version>1.2</jsp-version>

    

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

    

<tag>

    

<name>hello</name>

    

<tag-class>HelloTag</tag-class>

    

<body-content>empty</body-content>

    

</tag>

    

</taglib>

    



    



    

4. Installing the tld file. Tag library descriptor files charge to be attainable

    

by the bobcat server. So I affected HyTaglib.tld to

    

localjakarta-tomcat-4.1.18webapps
ootweb-inf lds directory.

    



    

5. Autograph the JSP page. To use my first custom tag, I wrote the afterward

    

JSP page, hello_tag.jsp:

    

 

    

<?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">

    

<!-- hello_tag.jsp

    

Absorb (c) 2003 by Dr. Yang

    

-->

    

<jsp:directive.page import="HelloTag"/>

    

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

    

<html><body>

    

<hy:hello/>

    

</body></html>

    

</jsp:root>

    



    



    

6. Examination the JSP page. To see the achievement of my JSP page, I affected hello_tag.jsp

    

to localjakarta-tomcat-4.1.18webapps
oot, started bobcat 4.1.18 server, and

    

use Internet Explorer (IE) to appearance http://localhost:8080/hello_tag.jsp.

    



    

7. I did get the "Hello world!" bulletin in the IE window. So my accost tag formed perfectly.

    



    

8. If you are alteration your tag chic afterwards it has been loaded by tomcat,

    

you may charge to restart tomcat, or bang "restart" on the "root" appliance

    

on the bobcat admin page. "root" appliance is area I put my JSP pages.

    



    

How Custom Tag Works

    



    

Here is my compassionate of how custom tag works, using the "Hello world!" tag as

    

an example:

    



        

  • When "hello_tag.jsp" page is requested for the first time, Bobcat server will

        

    translate the JSP page into a java class.

        



  •     

  • When the <hy:hello/> custom tag is encountered during the translation,

        

    Tomcat server will chase the tld book to locate the HelloTag.class file.

        

    Note that the tld book is provided in the "jsp:root" element.

        



  •     

  • Then Bobcat server will alter the custom tag with some java cipher

        

    to instantiate an item of the tag class, initialize the object, and alarm

        

    the doStartTag() method.

        



  •     

  • To achievement data into page, you can get an achievement beck from the

        

    pageContext item provided by the JSP tag addendum facility, pageContext.getOut().

        

    This is how the "Hello world!" bulletin gets produced in the IE window.

        



  •     

  • Note that I accept to use "jsp:directive.page" to acceptation HelloTag chic into

        

    the JSP page, because my HelloTag chic has no java amalgamation name and needs

        

    to be imported, even if it is amid in the chic path.

        



  •     



    



    



    



 


 class, tomcat, custom, version, server, hellotag, hytaglib, world, object, output, directive, library, taglib, , jsp page, custom tag, < jsp, tag class, tld file, tag jsp, tomcat server, hytaglib tld, html <, hellotag class, directive page, server will, < body, tag library, < tag, jsp root, jsp directive, tomcat server will, jsp directive page, tag library descriptor, tutorials tutorial notes, jstl tutorials tutorial,

Share JSP and JSTL Tutorials - Tutorial Addendum - JSP Custom Tag:
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 ...

JSP and JSTL Tutorials - Tutorial Addendum - JSP Tag Aspect Administration
Tag Aspect Setter MethodThe JSP tag addendum ability maps anniversary aspect encountered in a customtag to an acreage of the aforementioned name of the tag object. So if you wish b

JSP and JSTL Tutorials - Tutorial Addendum - JSP Tag Aspect Administration
i(Continued from antecedent part...)/iTag Aspect Amount Blazon ConversionIn my antecedent example, the aspect amount is anesthetized to the tag item propertyas a cord

JSP and JSTL Tutorials - Tutorial Addendum - JSP Tag Aspect Administration
i(Continued from antecedent part...)/iThe JSP file: <?xml version="1.0"?<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:c="http://java.sun.com/jstl/core"

JSP and JSTL Tutorials - Tutorial Addendum - JSP Tag Aspect Administration
i(Continued from antecedent part...)/iTag Aspect Amount Announcement Archetype AttObjectTag.javaThe tag class: /** * AttObjectTag.java

JSP and JSTL Tutorials - Tutorial Addendum - JSP Tag Java Interface
javax.servlet.jsp.tagext.* Packagejavax.servlet.jsp.tagext.* is a Java amalgamation authentic in J2EE (I saw it in J2EE 1.3.1). This amalgamation contains:

JSP and JSTL Tutorials - Tutorial Addendum - JSP Tag Java Interface
i(Continued from antecedent part...)/iImplenting BodyTag Interface TraceTag.javaIn adjustment to affirm my compassionate of the IterationTag interface, I wrotethe af

JSP and JSTL Tutorials - Tutorial Addendum - JSP Tag Java Interface
i(Continued from antecedent part...)/iThe Servlet Chic TraceTagTest_jsp.javaAs we all understand that JSP pages are translated into Servlet classes beforeexecution.

JSP and JSTL Tutorials - Tutorial Addendum - Tags Alive Calm
Nested JSTL TagsWhen tags are nested, JSP tag addendum ability offers the adolescent tag anaccess to the ancestor tag by the setParent() adjustment call. You can yield advantage

JSP and JSTL Tutorials - Tutorial Addendum - Tags Alive Calm
i(Continued from antecedent part...)/iI am abiding you can apprehend this page, and accept what I am accomplishing with the loop. Warning, my "break" tag is not a absolutely breach statement. If there is any addi

JSP and JSTL Tutorials - Tutorial Addendum - Bobcat 4.1.18 with JDK 1.4.1
This affiliate explains:How to change Bobcat 4.1.18 accession from using JDK 1.3.1 to using JDK 1.4.1.Compilation issues of using JavaBean classes in bearding packages.