JSP custom tag

All

Intro

Similar to ASP, which uses C#, JSP is the one with uses Java behind. To deploy those applications we need a servlet container, like Apache Tomcat or JBoss EAP – Undertow. JSP dynamic web content, as XML. Together.

Deploy

We need a servlet container so in this case, we can use Jetty for the demonstration. Eclipse Jetty is a Java HTTP (Web) server and Java Servlet container, I will talk more about it on another post.

JSP Custom TAG

One of the most interesting features in my opinion about JSP, which is a nice feature btw, is the possibility to create custom tags HTML based on the HTML rules – ofc. Just follow the template below with the attributes you need.

    TEMPLATE FOR HTML 4

<?xml version=”1.0″ encoding=”UTF-8″ ?>

<!DOCTYPE taglib
PUBLIC “-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN”
http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd”&gt;

<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>name</short-name>
<uri>/put_your_uri</uri>
<display-name>x</display-name>
<description>JSP Tag library for CPS application </description>
<tag>
<name>your_tag_name</name>
<tag-class>your_tag</tag-class>
<body-content>JSP</body-content>
<display-name> Any content</display-name>
<description>Example</description>
<attribute>

</attribute>

JSP Html 4 vs Html 5

Jsp will validate the HTML version on the begin of the page. Please use plain simple JavaScript in case you need validation.

 

JSP Specification

We can see the specification here

REFs

[1] https://download.oracle.com/otn-pub/jcp/jsp-2.2-mrel-oth-JSpec/jsp-2_2-mrel-spec.pdf?AuthParam=1549126534_f78333269b1bd20bab4bfcb8700cd010

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s