Standard Action tags JSP

Standard Action tags JSP

Standard Action tags JSP specify the behavior of JSP container. JSP comes with 10 action tags. Each action tag has a specific job to perform.

Action tags are used in coding to control the flow among JSP pages, to forward the client request to another page, to use with JavaBeans and to dynamically insert a file content in another etc. Actions are written in XML syntax.

General Syntax: <jsp:action_name attribute_name="value_to_give" />

Example: <jsp:include page="Demo.jsp" />

1. 10 List of Standard Action tags JSP given in the order they are used often.

S. No. Action Name What for used?
1 jsp:include includes content of a JSP/HTML file in the main file dynamically at request time
2 jsp:forward forwards to a new page to process the client request
3 jsp:useBean Searches and links the JSP page to a JavaBean
4 jsp:setProperty calls set() method of JavaBean and sets a property
5 jsp:getProperty calls get() method of JavaBean and places property value directly in the client output
6 jsp:plugin Used with EMBED or OBJECT to write code for plugin
7 jsp:element used with XML elements
8 jsp:body used with XML body element
9 jsp:text to write text for pages used as template
10 jsp:attribute used with attribute of an XML element

First 5 are used very often in coding and the last 5 are used rarely.

2. Two Common Attributes applicable to all actions

There are two attributes that can be used by all action elements – id and scope.

id It is an unique ID given and used by container to identify action element.
scope Identifies the life span of attribute. Scope value can be request, session, page and application.

Leave a Reply

Your email address will not be published. Required fields are marked *