Friday, February 8, 2013

Head First Servlets and JSP: Chapter 10 Custom Tag Development

1- Before, we were using <jsp:include> and <c:import> to add reusable pages, however with <jsp:include> and <c:import> you should create request parameters in order to pass them.


2- we can do the same thing with  tags, the same jsp file (the one we want to reuse), we can change the extension from jsp to .tag. with tags you pass parameters as attributes


the figure above shows how you can create a tag


now in order to pass parameters you wirte

<myTags:Header subTitle="asdfasdf" />

and you read this value from the taf file like this

<strong>${subTitle}</strong>

3- as you remeber we add the attribute for tags in TLD, however tag files have special directive called attribute:


4- for complex tags, you can define them as a java class


5- SkipPageException, inside the tag you can throw SkipPageException, this exception will not render the rest of the page.

Other information about Tags are in the chapter, you can read it 

No comments:

Post a Comment