Using Taglib to Implement Dynamic UI

What's Taglib?

Taglib is a JSP extension feature to allow developer to define complex UI interactivation in java code.  It can simplify the code and logical in JSP page and we can control the JSP page display in java code. 

 

How to implement Taglb?

Any java code that wants control JSP page display through Taglib should extend class: javax.servlet.jsp.tagext.TagSupport provided by JSP container.

 

javax.servlet.jsp.tagext.TagSupport

There are two methods in TagSupport:

public int doStartTag() ;

When JSP parsing element "<", "doStartTag()" method will be invoked.  Normally this method is used for business logical execution.

 

public int doEndTag();

When JSP parsing element ">", "doEndTag()" method will be invoked.  Normally this method is used to output UI display.


SetXXX: Transmit parameters to TagSupport

Any attibute in elements' definition equivalent to a "setXXX" method in java code that implement "TagSupport".

This "setXXX" method is used to transmit parameters from JSP page to Java code.

 

How to use Taglib in JSP Page?

Like any other JSP technologies, JSP container will manage the JSP display according to your Taglib implementation. So how to notice JSP container your Taglib implementation?

 

  1. Step 1: define your implementation in TLD (tag libraries descriptor)
  2. Step 2: import your TLD in JSP file. 
  3. Step 3: Using taglib as a normal html tag: <myTag:doSomething attribute1="*"/>

 

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值