Updates
  • Starting New Weekday Batch for Full Stack Java Development on 27 September 2025 @ 03:00 PM to 06:00 PM
  • Starting New Weekday Batch for MERN Stack Development on 29 September 2025 @ 04:00 PM to 06:00 PM

JSP Standard Actions

Folllowing are the important JSP Standard actions.

<jsp:include>
<jsp:forward>
<jsp:param>
<jsp:useBean>
<jsp:setProperty>
<jsp:getProperty>

<jsp:include>

<jsp:include> is used to include one JSP or html inside another JSP.
<jsp:include> will include the response of the the included page at runtime.

Syntax:

<jsp:include page="jsp or html file"/>

EX:

<jsp:include page="header.jsp"/>
<jsp:include page="footer.html"/>
<jsp:include> functionality is similar to include() method of RequestDispatcher.
<%
request.setAttribute("email","som@jtc");
RequestDispatcher rd=request.getRequestDispatcher("header.jsp");
rd.include(request,response);
%>

<jsp:forward>

<jsp:forward> is used to forward the control from one JSP to another JSP or html .

Syntax:

<jsp:forward page="jsp or html file"/>

EX:

<jsp:forward page="hello.jsp"/>
<jsp:forward> functionality is similar to forward() method of RequestDispatcher.
<%
request.setAttribute("email","som@jtc");
RequestDispatcher rd=request.getRequestDispatcher("hello.jsp");
rd.forward(request,response);
%>

<jsp:param>

<jsp:param> is used to send the parameter data from One JSP to another JSP while you are including or forwarding.
<jsp:param> must be used along with <jsp:include> or <jsp:forward>

Syntax:

<jsp:param name="email" value="som@jtc.com"/>

EX:

<jsp:include page="header.jsp">
<jsp:param name="email" value="som@jtc.com"/>
</jsp:include>
<jsp:forward page="home.jsp">
<jsp:param name="email" value="som@jtc.com"/>
</jsp:include>

Files Required For Program

1. header.jsp
2. footer.jsp
3. home.jsp
4. test.jsp
5. javaDetails.jsp
6. pythonDetails.jsp
7. webDetails.jsp
8. web.xml

1. header.jsp

            
<header>
    <h3> ${param.companyName}Bookstore</h3>
    <br/><br/> 
 </header>
        
            

2. footer.jsp

            
<footer>
    <h3> ${param.companyName}All Rights Reserved.2023</h3>
    <br/><br/> 
 </footer>
        
            

3. home.jsp

            
<!DOCTYPE html> 
<html>
   <body>
      <jsp:include page="header.jsp">
         <jsp:param name="companyName" value="JTC"/>
      </jsp:include>
      <main>
         <br/> 
         <form action="test.jsp">
            <table>
               <tr>
                  <td>
                     <h2> Select Course </h2>
                  </td>
               </tr>
               <tr>
                  <td>
                     <select name="courseName">
                        <option value=""> ------ Select Course ----- </option>
                        <option value="Java"> Java Programming </option>
                        <option value="Python"> Python Programming </option>
                        <option value="Web"> Web Development </option>
                     </select>
                  </td>
               </tr>
               <tr>
                  <td> <input type="submit" value="Submit"/> </td>
               </tr>
            </table>
         </form>
      </main>
      <jsp:include page="footer.jsp">
         <jsp:param name="companyName" value="JTC"/>
      </jsp:include>
   </body>
</html>
        
            

4. test.jsp

            
<!DOCTYPE html> 
<html>
   <body>
      <h2> I am test.jsp</h2>
      <% 
         String cname= request.getParameter("courseName"); 
         if(cname.equals("Java")) { 
          %> 
      <jsp:forward page="javaDetails.jsp">
      <jsp:param name="couName" value="<%= cname %>"/>
      <jsp:param name="email" value="java@jtc.com"/>
      <jsp:param name="phone" value="12345"/>
      <% 
         } else if(cname.equals("Python")) { 
          %> 
      <jsp:forward page="pythonDetails.jsp">
         <jsp:param name="couName" value="<%= cname %>"/>
         <jsp:param name="email" value="pythin@jtc.com"/>
         <jsp:param name="phone" value="12345"/>
      </jsp:forward>
      <%
         } else if(cname.equals("Web")) { 
          %> 
      <jsp:forward page="webDetails.jsp">
         <jsp:param name="couName" value="<%= cname %>"/>
         <jsp:param name="email" value="web@jtc.com"/>
         <jsp:param name="phone" value="12345"/>
      </jsp:forward>
      <% 
         }%>
   </body>
</html>
        
            

5. javaDetails.jsp

            
<html>
   <body>
      <jsp:include page="header.jsp">
         <jsp:param name="companyName" value="JTC"/>
      </jsp:include>
      <hr/>
      <h3> Course Name : ${param.couName} </h3>
      <hr/>
      <h1> Java Full Stack CourseInfo</h1>
      <h1> Java Full Stack CourseInfo</h1>
      <h1> Java Full Stack CourseInfo</h1>
      <br/>
      Contact : <br/> 
      <br/> 
      <h3> Email : ${param.email} </h3>
      <h3> Phone : ${param.phone} </h3>
      <hr/>
      <jsp:include page="footer.jsp">
         <jsp:param name="companyName" value="JTC"/>
      </jsp:include>
   </body>
</html>
        
            

6. pythonDetails.jsp

            
<html>
   <body>
      <jsp:include page="header.jsp">
         <jsp:param name="companyName" value="JTC"/>
      </jsp:include>
      <hr/>
      <h3> Course Name : ${param.couName} </h3>
      <hr/>
      <h1> Python Full Stack CourseInfo</h1>
      <h1> Python Full Stack CourseInfo</h1>
      <h1> Python Full Stack CourseInfo</h1>
      <br/> 
      Contact : <br/> 
      <br/> 
      <h3> Email : ${param.email} </h3>
      <h3> Phone : ${param.phone} </h3>
      <hr/>
      <jsp:include page="footer.jsp">
         <jsp:param name="companyName" value="JTC"/>
      </jsp:include>
   </body>
</html>
        
            

7. webDetails.jsp

            
<html>
   <body>
      <jsp:include page="header.jsp">
         <jsp:param name="companyName" value="JTC"/>
      </jsp:include>
      <hr/>
      <h3> Course Name : ${param.couName} </h3>
      <hr/>
      <h1> Web Developemnt CourseInfo</h1>
      <h1> Web Developemnt CourseInfo</h1>
      <h1> Web Developemnt CourseInfo</h1>
      <br/> 
      Contact : <br/> 
      <br/> 
      <h3> Email : ${param.email} </h3>
      <h3> Phone : ${param.phone} </h3>
      <hr/>
      <jsp:include page="footer.jsp">
         <jsp:param name="companyName" value="JTC"/>
      </jsp:include>
   </body>
</html>
        
            

8. web.xml

            
<?xml version="1.0" encoding="UTF-8"?> 
<web-app …>
   <display-name>Lab9</display-name>
   <welcome-file-list>
      <welcome-file>home.jsp</welcome-file>
   </welcome-file-list>
</web-app>
        
            

<jsp:useBean>

<jsp:useBean> is used to create the Java Bean object and to store that object in the required scope.

Syntax:

<jsp:useBean id="" class="" scope=""/>

EX:

<jsp:useBean id="STU" class="com.jtcindia.Student" scope="session">

<jsp:setProperty>

<jsp:setProperty> is used to set the value to the property of Java bean object.

Syntax:

<jsp:setProperty name="<id/attName>" property="<nameOfVariable>" value="..."/>

EX:

<jsp:setProperty name=" STU" property="name" value="Som"/>

<jsp:getProperty>

<jsp:getProperty> is used to get the value of the property of java bean object.

Syntax:

<jsp:getProperty name="<id/attName>" property="<nameOfVariable>"/>

EX:

<jsp:getProperty name=" STU" property="name"/>

Files Required For Program

1. test1.jsp
2. test2.jsp
3. Course.java
4. web.xml

1. test1.jsp

            
<%@ page import="com.jtcindia.jsp.Course"%> 
<!DOCTYPE html> 
<html>
   <body>
      <h3> Welcome to JTC</h3>
      <% 
         //1. Create the Course Object 
         Course cou = new Course(); 
         //2.Store Course Data 
         cou.setCourseId(101); 
         cou.setCourseName("Java Full Stack Course"); 
         cou.setDuration("550 Hrs"); 
         cou.setTrainer("SomPrakash Rai"); 
         //3.Store Course Object on Session Scope 
         session.setAttribute("MyCou", cou); 
         %> 
      <jsp:forward page="test2.jsp"/>
   </body>
</html>
        
            

2. test2.jsp

            
<%@ page import="com.jtcindia.jsp.Course"%> 
<!DOCTYPE html> 
<html>
   <body>
      <h3> Welcome to JTC</h3>
      <h3> --------------------------- </h3>
      <% 
         //4.Display Course Data 
         //Object obj = request.getAttribute("MyCou");
         Object obj = session.getAttribute("MyCou");
         if(obj!=null){ 
          Course mycou = (Course) obj; 
          out.println("<h3> Course Id : "+ mycou.getCourseId()+"</h3>"); 
          out.println("<h3> Course Name : "+ mycou.getCourseName()+"</h3>"); 
          out.println("<h3> Duration : "+ mycou.getDuration()+"</h3>"); 
          out.println("<h3> Trainer : "+ mycou.getTrainer()+"</h3>"); 
         }else{ 
          out.println("<h3> OOOPS!!! No Course Found : </h3>"); 
         } 
          %> 
   </body>
</html>
        
            

3. Course.java

            
package com.jtcindia.jsp;
public class Course {
   private int courseId;
   private String courseName;
   private String duration;
   private String trainer;
   //Setters and Getters 
}
        
            

4. web.xml

            
<?xml version="1.0" encoding="UTF-8"?> 
<web-app …>
   <display-name>Lab10</display-name>
   <welcome-file-list>
      <welcome-file>test1.jsp</welcome-file>
   </welcome-file-list>
</web-app>