Tuesday, 9 July 2013

Creating Custom JSP Tags

Hi,


You people all know how to create custom tags in class file using doStart,doEnd functions

Its cumbersome to use all that function and we have to define custom tags in web.xml also

Here i am going to show a simple method to create custom(User defined Tags)

Let me tell you for what purpose custom tags are used
  • To implement business logic
  • To hide important functionality
  • Code reuse
We get all the 9 default objects of jsp's in custom tag body. So we can access everything which is there in JSP. So get used to custom tags it will help u alot 
 Steps to create Custom tags
  1. Create a folder named "tags" in web-inf
  2. Right click on "tags" folder new->others->JSP Tag
Steps to use Custom tag in JSP file
  1. Have to add <%@taglib %> in that 
  2. Use "uri" attribute give path of "tags" folder 
  3. Use attribute "prefix" to use custom tag





No comments:

Post a Comment