JSP Action Element

In JSP we have action tags that we can use within the JSP pages. As scriptlet code is not used nowadays therefore, we use the action tags to remove the scriptlet code from the JSP page. These tags can also be used in the XML syntax to control the servlet engine. The action tags also called standard tags always begin with jsp: prefix.

The following are some of the JSP action tags that are used to perform certain tasks:

Action tags Description Usage
jsp: forward This tag is used to forward the request to a new JSP page. <jsp: forward page = “relative url” />
jsp: useBean This tag is used to instantiate a javaBean. <jsp: useBean id = “beanId” />
jsp: getproperty This tag is used to retrieve a property from an instance of javaBean. <jsp: useBean id= “beanId” />

<jsp:getProperty name=”beanId” property= “AnyProperty” />

In this example beanName is the name of the predefined bean whose property we are going to access.

 

jsp: setproperty This tag is used to store the data in property of instance of the JavaBean <jsp: useBean id= “beanId” />

<jsp: getProperty name = “beanId” property= “AnyProperty” value = “any value” />

In this example beanName is the name of the predefined bean whose property we are going to access.

 

jsp: include This tag is used to include the runtime response of the JSP into the present JSP page. It is used to include any file at the time when the page is requested.
jsp: plugin This tag is used to create code (browser specified) which is useful to make the OBJECT or EMBED tag for the java plugin.
jsp: fallback This tag is used to provide an alternative text that appears on the browser if the java plugin is not available for some reason. This text can be any message that will appear when the plugin is not loaded. < jsp: fallback >

Java plugin is not loaded

< / jsp: fallback >

 

 

jsp: element This tag is used to define dynamically the elements of XML <jsp: element name = “xmlElement” />

 

jsp: attribute This tag is used to define dynamically the attributes of the elements of XML.  

< jsp: attribute name = “attributeXMLElement” />

 

jsp: body This tag is used to within the standard tag to provide the body of the tag <jsp:body>

XML Element body

</jsp:body>

 

jsp: param This object is used to add parameters in the request object. < jsp: param name = “font color” value = “red” / >

 

jsp: text This tag is used to write text in the JSP pages and JSP documents. < jsp: text > Text < /jsp: text >