Watch “JSP Part-6 | Action Tag with example (Gujarati)” on YouTube

Jdk #Java #JSP #JavaServerPages #Scriplet #JSPActionTags #Gujarati #RaviROza #JspInclude #JSPForward

Video features the following:

  • usage of Action tag
  • jsp:include
  • jsp-forward
  • jsp-param
  • Actions tags are used to do things without using Java inside the scriptlets.
  • They are used to control the flow between pages and to use Java Bean.
  • They can be used for specific task such as including other resource, forward the request to other resource (html/jsp/servlet), working with java bean objects

Following are the list of files used in example

  • header.jsp
  • index.jsp
  • page1.jsp
  • page2.jsp

header.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Header</title>
</head>
<body>
<center>
<h1> Ravi R. Oza </h1>
<h4> Home Page </h4>
<hr>
</center>
</body>
</html>
index.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JSP Action Tag Demo</title>
</head>
<body>
<jsp:include page="header.jsp"></jsp:include>
<form action="page1.jsp">
<h1>JSP Action Tag Demo</h1>
<hr>
	<p> Enter your name 
		<input type="text" name="txtName">
	</p>
	<p>
		<input type="submit" value="Go to Page1">
	</p>

</form>
</body>
</html>
page1.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Page1</title>
</head>
<body>

<jsp:forward page="page2.jsp">
	<jsp:param value="Advance Java" name="txtSub"/>
</jsp:forward>

</body>
</html>
page2.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Testing Action tags with JSP Param</title>
</head>
<body>
<jsp:include page="header.jsp"></jsp:include>
<h1>Testing Action tags with JSP Param</h1>
<hr>
<p> Name : <%=request.getParameter("txtName") %>
<p> Subject : <%= request.getParameter("txtSub") %>
</body>
</html>

Summary:

  • Actions tags are used to do things without using Java inside the scriptlets.
  • They are used to control the flow between pages and to use Java Bean.
  • They can be used for specific task such as including other resource, forward the request to other resource (html/jsp/servlet), working with java bean objects

OS : Windows 10
Jdk : Version 8
IDE : Eclipse Mars
Server : Apache Tomcat 7

Follow me @
https://raviroza.wordpress.com/
https://raviroza.blogspot.com/
https://www.facebook.com/ravi.oza.it
https://twitter.com/raviozaIT

Subscribe my channel to get latest video notification https://www.youtube.com/user/ravioza101

Leave a Comment