Javaweb using JSP to develop if tags

Source: Internet
Author: User
Tags tld

<%@ Page Language="Java"Import="java.util.*"pageencoding="UTF-8"%><%@taglib prefix="T"URI="/web-inf/tag.tld"%><!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"><HTML><Head></Head><Body>    <%Request.setattribute ("User", "User"); %>    <t:ifTest= "${user==null}">Not yet logged in</t:if>    <t:ifTest= "${user!=null}">Welcome: ${user}</t:if></Body></HTML>
<?XML version= "1.0" encoding= "UTF-8"?><!--file name/web-inf/referer.tld -<taglibxmlns= "HTTP://JAVA.SUN.COM/XML/NS/J2EE"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "Http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"version= "2.0">    <tlib-version>1.0</tlib-version>    <Short-name>Anyname</Short-name><!--This value can be set arbitrarily -    <URI>AnyUri</URI><!--This URI can be set arbitrarily, but not the same as other. tld Files -    <Tag>        <name>If</name>        <Tag-class>De.bvb.web.tag.IfTag</Tag-class>        <body-content>Scriptless</body-content>        <attribute>            <name>Test</name>            <Required>True</Required>            <Rtexprvalue>True</Rtexprvalue>        </attribute>    </Tag></taglib>
 PackageDe.bvb.web.tag;Importjava.io.IOException;Importjavax.servlet.jsp.JspException;ImportJavax.servlet.jsp.tagext.SimpleTagSupport; Public classIftagextendsSimpletagsupport {Private Booleantest;  Public voidSettest (Booleantest) {         This. Test =test; } @Override Public voidDotag ()throwsjspexception, IOException {if(test) { This. Getjspbody (). Invoke (NULL);//Execute label Body        }    }}

Javaweb using JSP to develop if tags

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.