

{"id":82027,"date":"2020-09-10T09:00:04","date_gmt":"2020-09-10T03:30:04","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=82027"},"modified":"2021-08-25T13:47:14","modified_gmt":"2021-08-25T08:17:14","slug":"jsp-scripting-elements","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/jsp-scripting-elements\/","title":{"rendered":"JSP Scripting Elements &#8211; Expressions, Scriptlets, Declarations"},"content":{"rendered":"<p>This article discusses the scripting elements and their use in JSP. It has a detailed description of the scriptlets, expressions, declarations in JSP. An additional element i.e. JSP comments have also been mentioned. This article tells about their importance in JSP code.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/JSP-Scripting-Elements.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-82048\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/JSP-Scripting-Elements.jpg\" alt=\"JSP Scripting Elements\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/JSP-Scripting-Elements.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/JSP-Scripting-Elements-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/JSP-Scripting-Elements-1024x536.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/JSP-Scripting-Elements-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/JSP-Scripting-Elements-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/JSP-Scripting-Elements-520x272.jpg 520w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<h2>JSP Scripting Elements<\/h2>\n<p>JSP scripting elements are one of the most vital elements of a JSP code. These &lt;% %&gt; tags contain JSP scripting elements. These tags are of the utmost importance as, at the time of translation, the JSP engine will consider anything inside these tags. Only this code will convert to Java code. Code other than this is plain or HTML text.<\/p>\n<p>The scripting elements thus help to embed java code to the HTML, CSS, JavaScript code. There are three main subdivisions of scripting elements in JSP.<\/p>\n<p>1. Expression Tags<br \/>\n2. Scriptlet Tags<br \/>\n3. Declaration Tags<\/p>\n<p>They all provide different ways to include java code in a JSP file.<\/p>\n<h3>1. Scriptlets in JSP<\/h3>\n<p>JSP Scriptlets help in embedding Java in HTML for JSP code. &lt;%___%&gt; tags contain the Java code and are called as scriptlet tags. Unlike expressions, scriptlets have a set of statements in Java language. It allows writing java code in it. The Syntax of Scriptlet tag is as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;% statement; statement ;\u2026.%&gt;<\/pre>\n<p>The code inside a scriptlet tag goes to the _jspService() method of the generated servlet for processing the request. For each request sent, the _jsp service() method will invoke. If multiple scriptlets are present in the code, then they are appended to this service method in an ordered fashion.<\/p>\n<p><strong>For Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">scriptlet.jsp\r\n&lt;html&gt;\r\n&lt;head&gt;&lt;title&gt;Scriptlets&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;h3&gt;--DataFlair--&lt;\/h3&gt;\r\n&lt;h3&gt;Use of scriptlet in JSP&lt;\/h3&gt;\r\n      \t&lt;% int a=3;\r\n      \t   int b=4;\r\n      \t   int c=5;\r\n      \t   out.println(\"a is: \" +a+ \"&lt;br&gt;\" + \"b is:\" +b+ \"&lt;br&gt;\" + \"c is:\" +c+ \"&lt;br&gt;\");\r\n      \t   out.println(\"Multiplication gives: \" + a*b*c + \"&lt;br&gt;\");\r\n      \t   out.println(\"Addition gives:\" + (a+b+c));\r\n      \t%&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>Explanation<\/strong><\/p>\n<p>The above code shows the use of a scriptlet tag that embeds the java code in it. The code inside the scriptlet tag will go _jspService() method and will become pure java code. The following is the output.<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image5-7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-82056\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image5-7.png\" alt=\"scriptlets in JSP\" width=\"1366\" height=\"285\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image5-7.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image5-7-300x63.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image5-7-1024x214.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image5-7-150x31.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image5-7-768x160.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image5-7-520x108.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3>2. JSP Expressions<\/h3>\n<p>JSP Expression tags, as the name suggests, evaluates expressions. They incorporate arithmetic and logical expressions so that they can be evaluated. They form an easy means to access the value of a Java variable. The Expressions in JSP can be an access point for other expressions and merge that value in an HTML file. They can easily access data stored in applications.<\/p>\n<p><strong>Syntax of the expression is:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;%=expression\/statement %&gt;\r\n<\/pre>\n<p>This code will get written to the output stream of the response.<\/p>\n<p>These expressions or statements can be any valid Java statement. This code gets converted to out.print( ) statement when an auto generated servlet gets formed. Use of expressions generates scriptless code.<\/p>\n<p>Following are the examples of expressions in JSP.<\/p>\n<h4>a. expression.jsp<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt;\r\n&lt;head&gt;&lt;title&gt;Expressions&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;h3&gt;--DataFlair--&lt;\/h3&gt;\r\n&lt;h3&gt;Use of Expressions in JSP&lt;\/h3&gt;\r\n&lt;% String s1=\"expressions: done by kajal\"; %&gt;\r\n&lt;% out.print(s1); %&gt; &lt;\/br&gt;\r\n&lt;%=s1.toUpperCase() %&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt; \r\n<\/pre>\n<h4>b. expression2.jsp<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt;\r\n&lt;head&gt;&lt;title&gt;Expressions2&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;h3&gt;--DataFlair--&lt;\/h3&gt;\r\n&lt;h3&gt;Use of Expressions in JSP&lt;\/h3&gt;\r\n&lt;% int n1=10, n2=20; %&gt;\r\n&lt;% out.print(\"Addition of numbers is =\"); %&gt;\r\n&lt;%=n1+n2 %&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>Explanation<\/strong><\/p>\n<p>1. In this example, we can see the use of expression to get the result of the logical expression. The result is shown in the output below.<br \/>\nOutput:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image4-7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-82055\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image4-7.png\" alt=\"jsp expressions\" width=\"1366\" height=\"225\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image4-7.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image4-7-300x49.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image4-7-1024x169.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image4-7-150x25.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image4-7-768x127.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image4-7-520x86.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>2. Contrary to the first example, we can see the use of arithmetic in the JSP code. The output is below.<br \/>\nOutput:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image3-8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-82057\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image3-8.png\" alt=\"JSP Expressions\" width=\"1366\" height=\"213\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image3-8.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image3-8-300x47.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image3-8-1024x160.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image3-8-150x23.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image3-8-768x120.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image3-8-520x81.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h3>3. JSP Declarations<\/h3>\n<p>Declarations in JSP declare java language statements. &lt;%!___%&gt; tags contain declarations. They can declare classes\/instances\/inner classes\/variables\/methods.<\/p>\n<p>Unlike the other two, this code doesn\u2019t go to _jspService() method. This code rather goes to the source file that gets generated outside the _jspService method.<\/p>\n<p><strong>Syntax for declarations are:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;%! statement,[statement,\u2026.] %&gt;<\/pre>\n<p>Declarations have no access to implicit objects as they don\u2019t appear in the service method. A declaration will remain outside the service method. If a method declared under declaration wants to access an object from scriptlet then it needs to pass the object as parameter.<\/p>\n<p><strong>Example of declaration in JSP:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Declaration.jsp\r\n&lt;html&gt;\r\n&lt;head&gt;&lt;title&gt;Declaration&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;h3&gt;--DataFlair--&lt;\/h3&gt;\r\n&lt;h3&gt;Use of Declaration in JSP&lt;\/h3&gt;\r\n      \t&lt;%! int num1=2, num2=3, n=0; %&gt;\r\n      \t&lt;% n=num1+num2+1;\r\n    \tout.println(\"The number after adding declared variables is \" + n);\r\n      \t%&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>Explanation:<\/strong><br \/>\nIn this code, we declared num1 and num2. Then we performed calculations on it. It will thus generate the following output.<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image1-10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-82052\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image1-10.png\" alt=\"JSP Declaration tags\" width=\"1366\" height=\"217\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image1-10.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image1-10-300x48.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image1-10-1024x163.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image1-10-150x24.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image1-10-768x122.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image1-10-520x83.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h3>Difference Between JSP Scriptlet tag and Declaration tag<\/h3>\n<table>\n<tbody>\n<tr>\n<td><b>JSP Scriptlet tag<\/b><\/td>\n<td><b>JSP Declaration tag<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Only variables can be declared.<\/span><\/td>\n<td><span style=\"font-weight: 400\">Methods as well as variables can be declared.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">The declaration inside this tag goes inside the _jspService() method.<\/span><\/td>\n<td><span style=\"font-weight: 400\">The declaration inside this tag goes to the generated source file outside the _jspService() method.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>There is an additional element that is considered as a scripting element and that is Comments.<\/p>\n<h3>JSP Comments<\/h3>\n<p>Comments increase the understanding of the code. They will not be there in the output. Browser or the container ignores them. They are simply statements that can explain the code.<\/p>\n<p>There are two types of comments in JSP. They are:<\/p>\n<ul>\n<li>JSP code contains JSP comments. JSP container ignores these comments. They are hidden comments as they are not sent to the output stream.<\/li>\n<\/ul>\n<p><strong>The syntax of a JSP comment is as follows:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;%----Comments ignored by container----%&gt;\r\n<\/pre>\n<ul>\n<li>Secondly, the HTML comments. They go in the XML or HTML code. Browser ignores these comments whereas a JSP container treats them as an HTML tag. They can be visible under view source.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;!----Comments ignored by browser----!&gt;<\/pre>\n<p><strong>For Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">comments.jsp\r\n&lt;html&gt;\r\n&lt;head&gt;&lt;title&gt;Comments&lt;\/title&gt;\r\n&lt;!---This is an HTML comment---&gt;\r\n&lt;h6&gt;--DataFlair--&lt;\/h6&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n \r\n&lt;%---This is a JSP comment---%&gt;\r\n&lt;% int a=1;\r\n   \tint b=2;\r\n  \tout.println(\"The addition of a and b is:\" + a+b);\r\n%&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>Explanation:<\/strong><br \/>\nWe have used both HTML as well as JSP comments. Both the commented lines are not there in the output below:<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image2-9.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-82054\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image2-9.png\" alt=\"\" width=\"1366\" height=\"170\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image2-9.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image2-9-300x37.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image2-9-1024x127.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image2-9-150x19.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image2-9-768x96.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/image2-9-520x65.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<p>There are some special constructs that we can use to insert comments in JSP, so that they can be treated specially. They are:<\/p>\n<table style=\"height: 440px\" width=\"781\">\n<tbody>\n<tr>\n<td><b>S.NO.<\/b><\/td>\n<td><b>JSP Construct<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">1.<\/span><\/td>\n<td><span style=\"font-weight: 400\">&lt;%___%&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">This is a comment in JSP code.JSP engine ignores this comment.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">2.<\/span><\/td>\n<td><span style=\"font-weight: 400\">&lt;!____!&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Browser ignores this comment as it is an HTML comment.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">3.<\/span><\/td>\n<td><span style=\"font-weight: 400\">&lt;\\%<\/span><\/td>\n<td><span style=\"font-weight: 400\">This will represent start of a static literal<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">4.<\/span><\/td>\n<td><span style=\"font-weight: 400\">%\\&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">This also shows static variables.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">5.<\/span><\/td>\n<td><span style=\"font-weight: 400\">\\\u2019<\/span><\/td>\n<td><span style=\"font-weight: 400\">This represents Single quoted attributes that will use single quotes<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">6.<\/span><\/td>\n<td><span style=\"font-weight: 400\">\\\u201d<\/span><\/td>\n<td><span style=\"font-weight: 400\">This represents Double quoted attributes that will use double-quotes.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Conclusion<\/h2>\n<p>Inferring from the above article, we discussed the use of JSP scripting elements to embed java code in HTML, CSS, JavaScript. We learned about the subdivisions of scripting elements like scriptlet tag, expression tag, declarations. Then we also discussed an additional element called Comments. We saw their applications as well with the help of examples.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article discusses the scripting elements and their use in JSP. It has a detailed description of the scriptlets, expressions, declarations in JSP. An additional element i.e. JSP comments have also been mentioned. This&#46;&#46;&#46;<\/p>\n","protected":false},"author":10,"featured_media":82048,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22403],"tags":[23237,23238],"class_list":["post-82027","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jsp","tag-jsp-scripting-elements","tag-scripting-elements-in-jsp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JSP Scripting Elements - Expressions, Scriptlets, Declarations - DataFlair<\/title>\n<meta name=\"description\" content=\"Scripting elements provide ability to insert Java code inside JSP. They are of 3 types in JSP: JSP scriptlet tag; JSP declaration tag; JSP expression tag.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/jsp-scripting-elements\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JSP Scripting Elements - Expressions, Scriptlets, Declarations - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Scripting elements provide ability to insert Java code inside JSP. They are of 3 types in JSP: JSP scriptlet tag; JSP declaration tag; JSP expression tag.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/jsp-scripting-elements\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-09-10T03:30:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-25T08:17:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/JSP-Scripting-Elements.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JSP Scripting Elements - Expressions, Scriptlets, Declarations - DataFlair","description":"Scripting elements provide ability to insert Java code inside JSP. They are of 3 types in JSP: JSP scriptlet tag; JSP declaration tag; JSP expression tag.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/jsp-scripting-elements\/","og_locale":"en_US","og_type":"article","og_title":"JSP Scripting Elements - Expressions, Scriptlets, Declarations - DataFlair","og_description":"Scripting elements provide ability to insert Java code inside JSP. They are of 3 types in JSP: JSP scriptlet tag; JSP declaration tag; JSP expression tag.","og_url":"https:\/\/data-flair.training\/blogs\/jsp-scripting-elements\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2020-09-10T03:30:04+00:00","article_modified_time":"2021-08-25T08:17:14+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/JSP-Scripting-Elements.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/jsp-scripting-elements\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/jsp-scripting-elements\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/a90b082e16aa38d207212d22b0581f33"},"headline":"JSP Scripting Elements &#8211; Expressions, Scriptlets, Declarations","datePublished":"2020-09-10T03:30:04+00:00","dateModified":"2021-08-25T08:17:14+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/jsp-scripting-elements\/"},"wordCount":951,"commentCount":1,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/jsp-scripting-elements\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/JSP-Scripting-Elements.jpg","keywords":["JSP scripting elements","scripting elements in JSP"],"articleSection":["JSP Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/jsp-scripting-elements\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/jsp-scripting-elements\/","url":"https:\/\/data-flair.training\/blogs\/jsp-scripting-elements\/","name":"JSP Scripting Elements - Expressions, Scriptlets, Declarations - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/jsp-scripting-elements\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/jsp-scripting-elements\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/JSP-Scripting-Elements.jpg","datePublished":"2020-09-10T03:30:04+00:00","dateModified":"2021-08-25T08:17:14+00:00","description":"Scripting elements provide ability to insert Java code inside JSP. They are of 3 types in JSP: JSP scriptlet tag; JSP declaration tag; JSP expression tag.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/jsp-scripting-elements\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/jsp-scripting-elements\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/jsp-scripting-elements\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/JSP-Scripting-Elements.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/JSP-Scripting-Elements.jpg","width":1200,"height":628,"caption":"JSP Scripting Elements"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/jsp-scripting-elements\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"JSP Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/jsp\/"},{"@type":"ListItem","position":3,"name":"JSP Scripting Elements &#8211; Expressions, Scriptlets, Declarations"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/a90b082e16aa38d207212d22b0581f33","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/dd6de0d647a0185cd6faf264e4ba860b0d85d08d7070766f9cd41bea5bb0b227?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/dd6de0d647a0185cd6faf264e4ba860b0d85d08d7070766f9cd41bea5bb0b227?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dd6de0d647a0185cd6faf264e4ba860b0d85d08d7070766f9cd41bea5bb0b227?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"The DataFlair Team is passionate about delivering top-notch tutorials and resources on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. With expertise in the tech industry, we simplify complex topics to help learners excel. Stay updated with our latest insights.","url":"https:\/\/data-flair.training\/blogs\/author\/dfadteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/82027","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=82027"}],"version-history":[{"count":4,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/82027\/revisions"}],"predecessor-version":[{"id":82058,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/82027\/revisions\/82058"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/82048"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=82027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=82027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=82027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}