суббота, 9 февраля 2013 г.

каcтом тег java

<jsp:doBody var="tagBody"/>

Create printBold.tag file in WEB-INF/tags and Copy below code in it.

And we can use this tagBody variable in our tag file like this : ${pageScope.tagBody}

Here tagBody is a variable jsp:doBodyВPget tag body and store it in tagBody variable.

To get body of tag we need to use :<jsp:doBody var=”tagBody”/>

<tags:printBold> This is in BoldВP</tags:printBold>

This tag file is an example of to get tag Body and modify it.

String printThis = "This is omt First Tag";

Create myPrint.tag file in WEB-INF/tags and Copy below code in it.

This tag print String in your jsp.

Use this line to include your tags in your jsp.

And I add this all tag in index.jsp .

Here I create four tags (.tag) file. Each contain different example.

Create tags folder in WEB-INF/tags as shown above image.

Create new Dynamic Web Project omtTag.

I used eclipse to create this example. So structure of this example shown in below image is same as eclipse Dynamic Web Project.

Tag files can be placed in one of two locations: in the /WEB-INF/tags/ directory or subdirectory of a web application or in a JAR file in the /WEB-INF/lib/ directory of a web application.

We use .tag file to make custom tag in jsp. TAG file is similar to .jsp file.

Java – How to make custom tag in jsp

Java - How to make custom tag in jsp | omt Lab

Комментариев нет:

Отправить комментарий