

{"id":80146,"date":"2020-08-11T09:00:00","date_gmt":"2020-08-11T03:30:00","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=80146"},"modified":"2021-08-25T13:48:06","modified_gmt":"2021-08-25T08:18:06","slug":"jsp-action-tags","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/jsp-action-tags\/","title":{"rendered":"JSP Action Tags &#8211; include, useBean, forward, param"},"content":{"rendered":"<p>JSP Action contains eleven action tags to perform specific tasks. These tasks include dynamic insertion of a file, controlling behaviour of the servlet engine, forwarding a user to another page, controlling flow between pages etc. In this article, we will see each of these JSP ACtion tags with syntax and examples. So let us begin!!!<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Action-Tags.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-80602\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Action-Tags.jpg\" alt=\"JSP Action Tags\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Action-Tags.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Action-Tags-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Action-Tags-1024x536.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Action-Tags-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Action-Tags-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Action-Tags-520x272.jpg 520w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<h2>JSP Action tags<\/h2>\n<p>Let us see various types of Actions tags in JSP. They are:<\/p>\n<ol>\n<li>jsp:include<\/li>\n<li>jsp:useBean<\/li>\n<li>jsp:setProperty<\/li>\n<li>jsp:getProperty<\/li>\n<li>jsp:forward<\/li>\n<li>jsp:plugin<\/li>\n<li>jsp:param<\/li>\n<li>jsp:body and<\/li>\n<li>jsp:elementjsp:attribute<\/li>\n<li>jsp:text<\/li>\n<li>jsp:output<\/li>\n<\/ol>\n<p>There are two important attributes that are common to all actions.<\/p>\n<ul>\n<li>id references the object uniquely created by actions,<\/li>\n<li>scope tells about the life of that object. Scope has 4 attributes namely page, application, session, and request.<\/li>\n<\/ul>\n<h3>1. &lt;java:include&gt;<\/h3>\n<p>This action is used to include the required resources like html,servlets and JSP.<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>Include action<\/strong><\/td>\n<td><strong>Include directive<\/strong><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">It includes resources dynamically at request time\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400;\">This includes resources at the time of translation<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">It works well for dynamic pages.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It works well for static pages.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>There are two attributes under include:<\/p>\n<p><strong>Page:<\/strong> its value is the url of the required resource.<br \/>\n<strong>Flush:<\/strong> it checks that the buffer of the resource is flushed before it is included.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;jsp:include page=\"page URL\" flush=\"true\/false\"&gt;<\/pre>\n<p><strong>Advantages of include actions are:<\/strong><br \/>\n1. It is best for dynamic pages.<br \/>\n2. It promotes code reusability as we include pages<br \/>\n3. It saves time as we can use one page again and again.<br \/>\n4. It can be created with or without parameters.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">main.jsp\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n &lt;title&gt;JSP Actions&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;jsp:include page=\"date.jsp\" flush=\"true\" \/&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n \r\ndate.jsp\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n &lt;title&gt;JSP Actions&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;p&gt;\r\nToday's date: &lt;%= (new java.util.Date()).toLocaleString()%&gt;\r\n&lt;\/p&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>Explanation:<\/strong><br \/>\nIn this example we can see that main.jsp includes date.jsp that gives date and time whereas date.jsp contains the code to retrieve date.<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/include1-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-80604\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/include1-1.png\" alt=\"include action tag in jsp\" width=\"1366\" height=\"157\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/include1-1.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/include1-1-300x34.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/include1-1-1024x118.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/include1-1-150x17.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/include1-1-768x88.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/include1-1-520x60.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h3>2. &lt;jsp:usebean&gt;<\/h3>\n<p>This action is used when we want to instantiate bean (many objects encapsulated in one object) class in our JSP page. It has following attributes:<\/p>\n<p>\u25cf id: id uniquely identifies bean in a specified scope.<br \/>\n\u25cf Scope<br \/>\n&#8211; Page: It is the default scope that states that we can bean within this JSP page.<br \/>\n&#8211; Request: This is broader than a page as bean can be used from any page that processes similar requests.<br \/>\n&#8211; Session: It has a wider range than above as bean can be used from any page in the same session.<br \/>\n&#8211; Application: It has the maximum range as bean can be used from any page present in the same application.<br \/>\n\u25cf Class: Creates object of bean class.<br \/>\n\u25cf Type: It gives the data type to the bean existing in the specified scope. It is useful with class and beanName.<br \/>\n\u25cf beanName: Uses the java.beans.Beans.instantiate() method and instantiates bean.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;jsp:useBean id= \"bean\"  scope= \"page\/(session\/request\/application)\" \r\nclass= \"package.class\"  type= \"package.class\"\r\nbeanName=\"package.class &gt;\r\n&lt;\/jsp:useBean&gt;\r\n<\/pre>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">square.java\r\nPackage demotest;\r\npublic class cube\r\n{\r\n  public int square(int n)\r\n  \t\t{return n*n*n;}\r\n}\r\n \r\nexample.jsp\r\n&lt;html&gt;\r\n&lt;title&gt;usebean&lt;\/title&gt;\r\n&lt;body&gt;\r\n&lt;jsp:useBean id=\"obj\" class=\"demotest.square\"\/&gt;\r\n  &lt;%\r\nint m=obj.cube(3);\r\nout.print(\"cube of 3 is \"+m);\r\n%&gt;\r\n&lt;\/body&gt;&lt;\/html&gt;\r\n<\/pre>\n<p><strong>Explanation:<\/strong><br \/>\nIn the java file square.java we prepare a basic class and in jsp file we invoke useBean. The object is thus instantiated using id as reference. We generate the cube of the given number.<\/p>\n<p>**Output has been shown with get and set property.<\/p>\n<h3>3. &lt;jsp:setProperty&gt;<\/h3>\n<p>jsp:setProperty and getProperty are used with usebeans. It is used to modify the properties of beans. It executes when new objects create. This has four attributes:<\/p>\n<ul>\n<li>name: It is literally the name of the bean whose property we want to set. It has the same name as the object we instantiated using usebean.<\/li>\n<li>\u00a0property: sets the property of the bean \u201c*\u201d means all the requests that match bean properties are included.<\/li>\n<li>\u00a0value: gives specific value to the bean.<\/li>\n<li>Param: a name that will fetch the value .<\/li>\n<\/ul>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;jsp:setProperty name=\u201cbean\u201d property= \u201c*\u201d|\r\nproperty=\u201cpropertyName\u201d value= \u201c&lt;%=expression&gt;\u201d|\r\nproperty=\u201cpropertyName\u201d param= \u201cParametername\u201d\r\n<\/pre>\n<p>**Example along with get property.<\/p>\n<h3>4. &lt;java:getProperty&gt;<\/h3>\n<p>This action gets the value of property and gives it out on the output as string. To get the property of a bean, bean and its name must be defined. It gets the value of the property where the property is the name of the bean property that was set by setProperty as well. The attributes of getProperty are:<\/p>\n<ul>\n<li>name: It gets the name of the bean whose property we need to get as its value.<\/li>\n<li>property: It defines the name of the property required for the bean.<\/li>\n<\/ul>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;jsp:setProperty name=\"bean\" property=\"message\" value=\"Myexample\" \/&gt;\r\n&lt;jsp:getProperty name=\"MyPage\" property=\"message\" \/&gt;\r\n<\/pre>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">TestBean.java\r\npackage demotest;\r\nimport java.io.Serializable;\r\npublic class TestBean implements Serializable\r\n {\r\nprivate String message = \"null\";\r\n \r\n      \tpublic String getMessage() {\r\n      \t return msg;\r\n }\r\n \r\n      \tpublic void setMessage(String message) {\r\n      \tthis.message = message;\r\n }\r\n}\r\n \r\nGetSet.jsp\r\n&lt;%@ page language=\"java\" contentType=\"text\/html; charset=ISO-8859-1\"\r\n      \tpageEncoding=\"ISO-8859-1\"%&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;title&gt;use bean, get set Property&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;jsp:useBean id=\"myBean\" class=\"demotest.TestBean\" \/&gt;\r\n&lt;jsp:setProperty name=\"myBean\" property=\"message\" value=\"GetSetActions\" \/&gt;\r\n&lt;jsp:getProperty name=\"myBean\" property=\"message\" \/&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>Explanation:<\/strong><br \/>\nA TestBean class of package demotest that implements serializable class has been defined that gets and sets the message using getters and setters. In jsp code, we use useBean action that will instantiate the object myBean.<\/p>\n<p>Then we set the property of the object and give it a value \u201cGetSetAction\u201d. Thereafter, using getProperty we fetch the value for myBean that was set as GetSetAction as our output.<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/1-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-80608 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/1-1.png\" alt=\"getproperty action tag in jsp\" width=\"1366\" height=\"123\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/1-1.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/1-1-300x27.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/1-1-1024x92.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/1-1-150x14.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/1-1-768x69.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/1-1-520x47.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h3>5. &lt;jsp:forward&gt;<\/h3>\n<p>This action as the name suggests forwards the request to another page. This other page can be static as well as a JSP page.<br \/>\n<strong>Syntax:\u00a0<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;jsp:forward =\u201cotherpage.jsp\u201d&gt;\r\n<\/pre>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Forward.jsp\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;title&gt;JSP Forward&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;a&gt;I was the requested page but forwarded the request to other&lt;\/a&gt;\r\n&lt;jsp:forward page=\"other.jsp\" \/&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n \r\nOther.jsp\r\n&lt;html&gt;\r\n&lt;title&gt;JSP Forward 2&lt;\/title&gt;\r\n&lt;h3&gt;DataFlair&lt;\/h3&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;a&gt;I am the other page where request is forwarded.&lt;\/a&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>Explanation:<\/strong> User calls main.jsp but gets forwarded to other.jsp<br \/>\n<strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/forward.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-80605\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/forward.png\" alt=\"forward action tag in jsp\" width=\"1366\" height=\"166\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/forward.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/forward-300x36.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/forward-1024x124.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/forward-150x18.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/forward-768x93.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/forward-520x63.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h3>6. &lt;jsp:plugin&gt;<\/h3>\n<p>Plugin embeds tags or inserts java objects into a JSP page. It has three attributes:<\/p>\n<ul>\n<li>\u00a0type: applet\/bean<\/li>\n<li>\u00a0code: It is the name of the class file.<\/li>\n<li>\u00a0codebase: It is the directory of the name of the class file.<\/li>\n<\/ul>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;jsp:plugin type=\"bean\/applet\" code=\"className\" codebase=\"package.class\"&gt;\r\n<\/pre>\n<p>**Example with param action.<\/p>\n<h3>7. &lt;jsp:param&gt;<\/h3>\n<p>It sends parameters to a bean or applet. Param acts as the child object of a plugin.<br \/>\n<strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;jsp:params&gt;\r\n&lt;jsp:param name=\u201c__\u201d value=\"__\"\/ &gt;\r\n&lt;\/jsp:params&gt;\r\n<\/pre>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">First.jsp\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;title&gt;Plugin Param &lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;jsp:plugin type=\"bean\" code=\"colour.class\" codebase=\"demotest.colour\"&gt;\r\n  &lt;jsp:params&gt;\r\n \t&lt;jsp:param name=\"id\" value=\"5\" \/&gt;\r\n     &lt;jsp:param name=\"nameofcolour:\" value=\"red\" \/&gt;\r\n  &lt;\/jsp:params&gt;\r\n&lt;\/jsp:plugin&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n \r\nColour.java\r\n package demotest;\r\nimport java.io.Serializable;\r\npublic class Colour implements Serializable {\r\n      \t\r\n      \tpublic String getName () {\r\n               \treturn name;\r\n      \t}\r\n      \tpublic void setName (String name) {\r\n               \tthis.name = name;\r\n      \t}\r\n      \tpublic int getId() {\r\n               \treturn id;\r\n      \t}\r\n      \tpublic void setId (int id) {\r\n               \tthis.id = id;\r\n      \t} \/\/getters and setters\r\n      \tprivate String name = \"null\";\r\n      \tprivate int id = 0;\r\n      \t\r\n}\r\n<\/pre>\n<p><strong>Explanation:<\/strong> In the First.jsp we are using plugin attributes type, code and codebase. In that we are having param child objects that get the name and value for the plugin. Whereas in Colour.java, we have used getters and setters to get and set the values of name and id.<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/PP.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-80606\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/PP.png\" alt=\"Param tag in jsp\" width=\"1366\" height=\"126\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/PP.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/PP-300x28.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/PP-1024x94.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/PP-150x14.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/PP-768x71.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/PP-520x48.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h3>8. &lt;jsp:body&gt;and &lt;jsp:element&gt;<\/h3>\n<p>In the body part of this action, we can define XML. Elements will be generated at runtime.<br \/>\n<strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;jsp:body&gt;.....\r\n         &lt;\/jsp:body&gt;\r\n&lt;jsp:element name= \u201c__\u201d&gt;\r\n         &lt;\/jsp:element&gt;\r\n<\/pre>\n<p>**Example of element, attribute, body together.<\/p>\n<h3>9. &lt;jsp:attribute&gt;&lt;\/jsp:attribute&gt;<\/h3>\n<p>Once we define XML, we can also define its attribute dynamically.<br \/>\n<strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;jsp:attribute name= \u201c__\u201d&gt;\r\n        &lt;\/jsp:attribute&gt;\r\n<\/pre>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt;\r\n&lt;head&gt;&lt;title&gt;ele attr body&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;jsp:element name=\"XMLelement\"&gt;\r\n&lt;jsp:attribute name=\"XMLattribute\"&gt;\r\n&lt;\/jsp:attribute&gt;\r\n&lt;jsp:body&gt; My example for element, attribute and body&lt;\/jsp:body&gt;\r\n&lt;\/jsp:element&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>Explanation:<\/strong> This code contains the example of element, attribute, body of a dynamically generated HTML.<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/ele.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-80603\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/ele.png\" alt=\"element action tag\" width=\"1366\" height=\"127\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/ele.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/ele-300x28.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/ele-1024x95.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/ele-150x14.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/ele-768x71.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/ele-520x48.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h3>10. &lt;jsp:text&gt;<\/h3>\n<p>It can contain template data, text or EL expressions.<br \/>\n<strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;jsp:test&gt;_____&lt;\/jsp:text&gt;<\/pre>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;title&gt;Template&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;jsp:text&gt;Here goes the template text.&lt;\/jsp:text&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>Explanation:<\/strong> Under jsp:text action we can output the template text.<br \/>\n<strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/template.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-80607\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/template.png\" alt=\"action tag in jsp\" width=\"1366\" height=\"121\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/template.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/template-300x27.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/template-1024x91.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/template-150x13.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/template-768x68.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/template-520x46.png 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h3>11. &lt;jsp:output&gt;<\/h3>\n<p>JSP output contains two attributes i.e doctype-root-element that will possess the root element of the generated XML and doctype-system that shows doctype that will be generated in output.<br \/>\n<strong>Syntax:\u00a0<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;jsp:output doctype-root-element=\"__\" doctype-system=\"__\"&gt;\r\n<\/pre>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;title&gt;Output action tag&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;jsp:output doctype-root-element=\"XML\" doctype system=\"http:\/\/www.myoutput.com\/.dtd\"\/&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>Explanation:<\/strong> This output is generated internally thus we can\u2019t infer output.<\/p>\n<h2>Conclusion<\/h2>\n<p>In reference to this article, we discussed different JSP action tags. Action tags perform dynamic insertion of a file, controlling behaviour of the servlet engine, forwarding a user to another page, controlling flow between pages etc. We saw eleven action tags, their attributes and values along with their codes. They are written in XML format.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JSP Action contains eleven action tags to perform specific tasks. These tasks include dynamic insertion of a file, controlling behaviour of the servlet engine, forwarding a user to another page, controlling flow between pages&#46;&#46;&#46;<\/p>\n","protected":false},"author":10,"featured_media":80602,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22403],"tags":[22929,22928,22927],"class_list":["post-80146","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jsp","tag-action-tags-in-jsp","tag-jsp-action","tag-jsp-action-tags"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JSP Action Tags - include, useBean, forward, param - DataFlair<\/title>\n<meta name=\"description\" content=\"Learn what are JSP action tags and various types of actions tags, their attributes and values along with their syntax and examples.\" \/>\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-action-tags\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JSP Action Tags - include, useBean, forward, param - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Learn what are JSP action tags and various types of actions tags, their attributes and values along with their syntax and examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/jsp-action-tags\/\" \/>\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-08-11T03:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-25T08:18:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Action-Tags.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=\"8 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JSP Action Tags - include, useBean, forward, param - DataFlair","description":"Learn what are JSP action tags and various types of actions tags, their attributes and values along with their syntax and examples.","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-action-tags\/","og_locale":"en_US","og_type":"article","og_title":"JSP Action Tags - include, useBean, forward, param - DataFlair","og_description":"Learn what are JSP action tags and various types of actions tags, their attributes and values along with their syntax and examples.","og_url":"https:\/\/data-flair.training\/blogs\/jsp-action-tags\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2020-08-11T03:30:00+00:00","article_modified_time":"2021-08-25T08:18:06+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Action-Tags.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":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/jsp-action-tags\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/jsp-action-tags\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/a90b082e16aa38d207212d22b0581f33"},"headline":"JSP Action Tags &#8211; include, useBean, forward, param","datePublished":"2020-08-11T03:30:00+00:00","dateModified":"2021-08-25T08:18:06+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/jsp-action-tags\/"},"wordCount":1113,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/jsp-action-tags\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Action-Tags.jpg","keywords":["action tags in jsp","jsp action","JSP Action Tags"],"articleSection":["JSP Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/jsp-action-tags\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/jsp-action-tags\/","url":"https:\/\/data-flair.training\/blogs\/jsp-action-tags\/","name":"JSP Action Tags - include, useBean, forward, param - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/jsp-action-tags\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/jsp-action-tags\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Action-Tags.jpg","datePublished":"2020-08-11T03:30:00+00:00","dateModified":"2021-08-25T08:18:06+00:00","description":"Learn what are JSP action tags and various types of actions tags, their attributes and values along with their syntax and examples.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/jsp-action-tags\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/jsp-action-tags\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/jsp-action-tags\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Action-Tags.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/08\/JSP-Action-Tags.jpg","width":1200,"height":628,"caption":"JSP Action Tags"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/jsp-action-tags\/#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 Action Tags &#8211; include, useBean, forward, param"}]},{"@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\/80146","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=80146"}],"version-history":[{"count":4,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/80146\/revisions"}],"predecessor-version":[{"id":86531,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/80146\/revisions\/86531"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/80602"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=80146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=80146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=80146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}