In this section we will learn about the JSP elements that we can use on a JSP page. This section will describe you all types of JSP elements that we can use on JSP page.
JSP elements are called the JSP tags on JSP page. On the JSP page mainly three groups of JSP elements are used :
JSP Scripting Elements
JSP Scripting Elements are used for writing the Java Code inside the JSP page. There are different types of scripting elements these elements are used for various purposes. Following are the scripting elements :
JSP Directive Elements
Directive elements in JSP provides the special information to the JSP engine. It gives the information about the JSP page. Each JSP page goes through the two phases i.e. translation phase and request time phase. At the translation phase JSP page is translated into a Servlet. The JSP engine translates the JSP page into a Servlet, directive elements are handled at the translation time. These directives are translated to the Servlet only for once, until there is no changes made to the directive elements in the Servlet.
JSP Directive Elements can be declared within the following special characters '<%@ %>'. Syntax for using directive in the JSP page is as follows :
<%@ directiveName attr1="value1" attr2="value2" %>
JSP Standard Action Elements
JSP Action Elements are used to take action on the basis of some information. These action elements can create, modify or use the other objects. Action elements are coded with the strict syntax they are used to apply the built-in functionality. Action elements are represented as <jsp:tagName> </jsp:tagName>. Code is written inside these tags, the <jsp:tagName> specifies the starting of the action tag where as the action tag is ends with </jsp:tagName>. When you are not required to defined the body of the tag you may end up the action tag by <jsp:tagName/>
JSP Comment Elements
JSP comment elements are used to hide your code from the "view page source". However, you can use HTML comment tags in JSP page but, when user of your website will choose the "view page source" then they can see your commented code. The JSP comment is denoted by the special character <%-- --%>. The special character '<%--' specifies the opening comment element and the special character '--%>' specifies the end of the comment tag.
HTML comment tag is denoted by the special characters '<!-- -->' where, '<!--' specifies the start tag and '-->' specifies the end tag.
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: July 1, 2013 If you enjoyed this post then why not add us on Google+? Add us to your Circles