Answer to Question #259125 in HTML/JavaScript Web Application for pooja

Question #259125

b) Explain with the help of an example/diagram or write code for the following using JSP:


a) b) Need of Directives in JSP with the help of taglib directive.

1
Expert's answer
2021-11-02T17:36:29-0400

The JavaServer Pages API allow you to define custom JSP tags that look like HTML or XML tags and a tag library is a set of user-defined tags that implement custom behavior.

The taglib directive declares that your JSP page uses a set of custom tags, identifies the location of the library, and provides means for identifying the custom tags in your JSP page.

The taglib directive follows the syntax given below

<%@ taglib uri = "uri" prefix = "prefixOfTag" >

Where, the uri attribute value resolves to a location the container understands and the prefix attribute informs a container what bits of markup are custom actions.

You can write the XML equivalent of the above syntax as follows

<jsp:directive.taglib uri = "uri" prefix = "prefixOfTag" />

When you use a custom tag, it is typically of the form <prefix:tagname>. The prefix is the same as the prefix you specify in the taglib directive, and the tagname is the name of a tag implemented in the tag library.


For example, suppose the custlib tag library contains a tag called hello. If you wanted to use the hello tag with a prefix of mytag, your tag would be <mytag:hello> and it will be used in your JSP file as follows

<%@ taglib uri = "http://www.example.com/custlib" prefix = "mytag" %>

<html>
   <body>
      <mytag:hello/>
   </body>
</html>

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS