Sunday, 28 September 2014

What are different JSP scriptlets ?

JSP provides different scriptlets to use java code in JSP.

1.Directives Tag

<%@ %>
-------------

This tag is used to include external content in our jsp

this tag has mainly three attributes

1.Page
2.taglib
3.include

<%@ taglib uri="relative UR""  prefix=""%>

when we have predefined,custom tags, we can include them in our JSP and use them with prefix.

<%@ page import="relaive url" %>

this works similar to import statement in Java.

<%@ include file="relative url"%>

include attribute can be used  to include external js,jsp and css files

file will  be included in our file during the translation phase.

II. Declarative tag
-----------------------
<%! %>
This tag is used to declare variables in JSP

<%! int a;%>

III. Expression tag
--------------------------

This tag is used to write any expressions which result in string.

<%=Expression%>

we should not use semicolon at the end of the expression


IV. JSP comments
-----------------------

<% -- comments---%>

used to write comments in JSP

No comments:

Post a Comment

Search This Blog