Jsp Tutorial Home

Jsp Home

JSP Resources

Community

Site








Different JSP tags




Different JSP Tags


There are following basic JSP elements which can be used with the JSP pages.




  1. Scriptlet Element.

  2. Expression Element.

  3. Declaration Element.

  4. Comments


The Scriptlet Element


Syntax :-<% Java Code %>



The simplest type of JSP element is the Scriptlet element. A
Scriptlet element is simply a section of Java code encapsulated within the
opening and closing JSP tags. The Scriplet is only applicable to the page in which it is declared and not in the other sub pages. The best part of the JSP is the power of directly using the Java Code with the HTML tags.


Example:- <% if(cond)%> is the sample code for the Scriplet.


Expression Element


Syntax: <%= code %>


The expression tag is used to print the output in the HTML format in the JSP page. In the last section we have just seen that it is used to output the String object on JSP page.


Declaration Element Syntax


Syntax: <%! code %>

The next type of Scripting element is the Declaration element.
The purpose of a Declaration element is to initialize variables and methods and
make them available to other Declarations, Scriptlets, and Expressions.


Comments


Syntax: <%-- comment --%> <!-- comment -->


There are two different types of comments in JSP. The difference
between the types of comments is that <%-- --%> comment is not viewable at the client side but the other one is viewable by selecting the view page source option.






                    

Copyright © 2014 VisualBuilder. All rights reserved