<div dir="ltr" style="text-align: left;">
<div dir="ltr" style="text-align: left;">
<p>Scripting elements are important part of JSP that makes page dynamic. Scripting elements can be classified in 3 categories:</p>
<p><b>1. Declaration Tags.</b><br />
<b>2. Expression Tags.</b><br />
<b>3. Scriptles.</b></p>
<p><b>Declaration Tags:</b> Declaration Tags is used to define variables and methods in JSP. Declaration Tags do not produce any output. Declaration Tag starts with <;%! and ends with %>;<br />
<b>Syntax.</b><;%! datatype variable = value; %>;</p>
<pre class="highlight"><;body>; 
 <;%! 
 int age = 25; 
 String name = "Dinesh"; 
 %>; 
 <;/body>; 
</pre>
<p><b>Expression Tags: </b>Unlike Declaration Tags, Expression Tags produce output that can be used to display result on JSP. Expression Tag starts with <;%= and ends with %>;<br />
<b>Syntax- <;%=variable %>;</b><br />
<b>Examaple</b> :</p>
<pre class="highlight"><;body>; 
 <;%=name %>; 
 <;%=age%>; 
 <;/body>; 
</pre>
<p><b>Scriptlets: </b>Scriptlets are useful when you want to include JAVA code inside JSP. You may want to create a function that can be used to generate output based on different parameters passed at run time. In this case you may want to create JAVA function in Scriptlets and than call this function in Expression Tags at multiple location in JSP to display result on browser. Scriptlets starts with <;% and ends with %>;.<br />
<b>Syntax-<;% out.println(&#8220;dineshonjava.com&#8221;) %>;</b><br />
<b>Examaple :</b></p>
<pre class="highlight"><;body>; 
 <;% 
 Date dob = new Date(); 
 out.println("Date of birth is "+dob); 
 out.println("dineshonjava.com"); 
 %>; 
 <;/body>; 
 
</pre>
<p><b>Complete example here</b><br />
<b>index.jsp</b></p>
<pre class="highlight"><;%@ page import="java.util.Date" %>; 
<;html>; 
 <;body>; 
 <;h1>; Declaration <;/h1>; 
 <;%! 
 int age = 25; 
 String name = "Dinesh"; 
 %>; 
 <;h1>;Expression <;/h1>; 
 <;%=name %>; 
 <;%=age%>; 
 <;h1>;Scriptlets<;/h1>; 
 <;% 
 Date dob = new Date(); 
 out.println("Date of birth is "+dob); 
 out.println("dineshonjava.com"); 
 %>; 
 <;/body>; 
 <;/html>; 
</pre>
<p>Copy the index.jsp file in to the webapp directory of tomcat.<br />
<b>C:Program Files (x86)Apache Software FoundationTomcat 7.0webappsindex</b></p>
<p>and start the server and hit the following url-<br />
<i><b>http://localhost:8080/index/index.jsp</b></i></p>
<p> ;</p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2013/09/1111-4.png" border="0" /></div>
</div>
<div style="background-color: pink; border-width: thin; text-align: center;"><b><;<;<a href="https://dineshonjava.com/creating-jsp-page-environment-setup/">Previous</a> <;<; || <a href="https://dineshonjava.com/jsp-tutorial-baby-step-to-server-pages/">Index </a>|| >;>;<a href="https://dineshonjava.com/jsp-directives/">Next</a> >;>;</b></div>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/creating-jsp-page-environment-setup/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/jsp-directives/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '347'});
});
</script>
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…