Department of CSE
ENTERPRISE PROGRAMMING
21CI2107
Topic:
Action tag
Session - 1
CREATED BY K. VICTOR BABU
AIM OF THE SESSION
To familiarize students with the basic concept of
INSTRUCTIONAL OBJECTIVES
This Session is designed to:
1. Demonstrate
2. Describe
3. List out the
4. Describe the
LEARNING OUTCOMES
At the end of this session, you should be able to:
1. Define
2. Describe
3. Summarize
CREATED BY K. VICTOR BABU
SESSION INTRODUCTION
Action tag
• The JSP specification provides a standard tag called Action tag used
within JSP code.
• It is used to remove or eliminate Scriptlet code from your JSP code as
JSP Scriptlets are obsolete and are not considered nowadays.
CREATED BY K. VICTOR BABU
SESSION INTRODUCTION
Action tag
• The action tag is also implemented to streamline flow between pages
and to employ a Java Bean.
• As it coincides with the XML standard, the syntax for the action
element is:
Syntax:
• <jsp:action_name attribute = "attribute_value" />
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION
Action tag
Here is the list of JSP Actions:
1.jsp:forward: 7. jsp:element:
2.jsp:include: 8. jsp:plugin:
3.jsp:body: 9. jsp:param:
4.jsp:useBean: 10.jsp:text:
5.jsp:setProperty: 11.jsp:fallback:
6.jsp:getProperty: 12.jsp:attribute:
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
Basic Attributes of Action Tags
Two basic attributes are commonly used for all action tags. These are:
1. id: The id attribute defines unique action elements and allows actions to be
referenced within the JSP page. When the action creates an object's instance, the id
attribute is used to refer to it.
2. Scope: The scope attribute is used for identifying an action's life cycle. It correlates
with the id attribute because the scope attribute is used to establish that particular
object's lifespan associated with the ID.
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
Example
jsp:include Action
Syntax: <jsp:include page = "Page URL" flush = "Boolean Value" />
Example:
<!DOCTYPE html>
<html>
<head>
<title>JSP include Action</title>
</head>
<body>
<h2>JSP page: with include</h2>
<jsp:include page="header.jsp" flush="false" />
</body>
</html>
CREATED BY K. VICTOR BABU
SESSION DESCRIPTION (Cont..)
Example
jsp:forward Action
Syntax: <jsp:forward page = "URL of another static, JSP, OR Servlet page" />
Example: <!DOCTYPE html>
<html>
<head>
<title>Example for Forward Action</title>
</head>
<body>
<h2>JSP page: Demo forward</h2>
<jsp:forward page="forward_eg.jsp" />
CREATED BY K. VICTOR BABU
</body>
SELF-ASSESSMENT QUESTIONS
1. Which tag should be used to pass information from JSP to included JSP?
(a) Using <%jsp:page> tag
(b) Using <%jsp:param> tag
(c) Using <%jsp:import> tag
(d) Using <%jsp:useBean> tag
2. Which is mandatory in <jsp:useBean /> tag?
(a) id, class
(b) id, type
(c) type, property
(d) type,id
CREATED BY K. VICTOR BABU
TERMINAL QUESTIONS
1. Describe
2. List out
3. Analyze
4. Summarize
CREATED BY K. VICTOR BABU
REFERENCES FOR FURTHER LEARNING OF THE SESSION
Reference Books:
1. JSP and Java servlet programming
2. The complete Reference JSP, Phil Hanna.
3. JSP And Servlets: A Comprehensive Study, Mahesh P. Matha
Sites and Web links:
1. https://www.tutorialspoint.com/jsp/jsp_actions.htm
2. https://www.w3schools.in/jsp/actions
3. https://www.javatpoint.com/jsp-action-tags-forward-action
CREATED BY K. VICTOR BABU
THANK YOU
Team – Course Name
CREATED BY K. VICTOR BABU