< Prev
Next >

JSP Scripting Elements

In JSP, there are three types of Scripting elements -

JSP Scriplets


<title>JSP Scriplet Tag</title>

<% out.println("Saying hello from Java using Scriplet Tag"); %>


on executing this web page,

Note - The code in JSP Scriplets tag is automatically executed as soon as the JSP page loads.

JSP Declarations

In a JSP page, JSP declarations are only used to declare -
These variables and methods are part of a Java code within our JSP page and hence they are accessible to the rest of Java code within other scriplet tags on the same webpage. We can declare java variables and methods within JSP Declaration tags such as - <%! %>


<title>JSP Declaration Tag</title>


<%! public void add()
int sum = 20 + 10;



JSP Expressions

Java expressions result in a value, hence JSP Expression tags are used to enclose java expressions that yield a value to be printed on a JSP web page. The Java expressions are enclosed in within <%= %> tags.

Please subscribe our social media channels for notifications, we post a new article everyday.

Decodejava Google+ Page Decodejava Facebook Page  DecodeJava Twitter Page

Coming Next