• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » JSP » Action Tags

jsp:useBean tag Example

By Dinesh Thakur

Jsp Beans known as a property attribute that is been used for the accessing the user of object the content may be java class or package that is been used to access the class field of object.

 

In simple words if we explain jsp beans this attribute use to access the property from a class file file must be java type or other as mentioned. In this example we use to display the property on the web browser we made a package named ‘p1’ in this we made a java file which class file will be use to access the data. In java file we create a program that is been use for getting and putting the value from property contents. Then we create a jsp file that will use the class file of java type while executing for output on the web browser. Attributes that are use to initialize like set property or beans id…let’s take a look on program.

<%@page import=”p1.jspbean”%>

<html>

   <head>

       <title>&lt;jsp_bean&gt;</title>

   </head>

   <body>

      <jsp:useBean id=”bean” class=”p1.jspbean”>

  <br><h3 align=”center”><jsp:setProperty name=”bean” property=”str” value = “Java Server Pages” /></center></br>

      </jsp:useBean>

   <p> <jsp:getProperty name=”bean” property=”str” /></p>

  </body>

  </html>

         jsp:useBean tag

Java File used In Program.

package p1;

public class jspbean

 {

    String str;

    public String getStr()

    {

       return str;

    }

       public void setStr(String str)

     {

        this.str = str;

    }

} 

JSP Forward Action Tag Example

By Dinesh Thakur

In this Example we will learn how to forward the client request or content on another web page. That requested content may be like HTML page, JSP or Servlet etc. The Main criteria of this example is to show how the content forward on another web page.

For this we also use two JSP forms in first we will use to enter the content which will have to forward on another web page as required in first form we use to code for design the web page. More we use HTML coding for that kind of designing criteria. We use attribute like forward page or param name for content referring. In the second page we create main functionality coding from that the output will be displayed on the web browser. The first form will use the redirection of the second one so that will execute both on the web browser as output. Some required JSTL tags or the java functions also use for this form…Lets Take a Look on The programmes…

  <html>

     <head>

       <title>&lt;JSP_forward&gt;</title>

     </head>

     <body>

       <jsp:forward page=”next.jsp”>

           <jsp:param name= “U_Name” value=”Yaduvanshi Ash”/>

      </jsp:forward>

    </body>

  </html>

 

 Next.jsp

<html>

    <head>

       <title>&lt;Forwarded_Action Example in JSP&gt;</title>

    </head>

     <body>

      <%

          String name= request.getParameter(“U_Name”);

      %>

      <%

          if(name != null)

         {

             %>

            <b><br><br><h2 align=”center”>

            <%=name%></h2></b></br>

            <%}

      %>

    </body>

   </html>

      JSP Forward Action Tag Example

Jsp appletPlugin Example

By Dinesh Thakur

In this Example we will discuss that we can include an applet or JavaBeans component in a JSP page by using the jsp:plugin element.

 

This will generates the HTML content that will contain the client-browser constructs. In the program we use java class for fetching the result an applet code also.Whenever this will be executed the appropriate output on the web browser.

<jsp:plugin type=”applet” code=”Pluginjsp.class” codebase=”p1″  width = “250” height = “250”>

<jsp:fallback>

       <p>Applet can’t be load</p>

</jsp:fallback>

</jsp:plugin>

 

Pluginjsp.java

import java.applet.*;

import java.awt.*;

import java.util.*;

import java.io.*;

public class Pluginjsp extends Applet

{

   public void paint(Graphics gr)

    {

      Calendar cl = new GregorianCalendar();

      String hr = String.valueOf(cl.get(Calendar.HOUR));

      String mnt = String.valueOf(cl.get(Calendar.MINUTE));

      String scnd = String.valueOf(cl.get(Calendar.SECOND));

      gr.drawString(hr + “:” + mnt + “:” + scnd, 20, 30);

   }

}

Jsp getProperty Example

By Dinesh Thakur

This example will explain that how we get the property from the beans components with getter method using. It will display the value on output destination. To implify this program we just got the java file and will fetch the property from java class file.

This java file only contain the getter method that is been used to access the output. We also made two form first one is for designing and will take the reference of 2nd form and second will does the rest of work to execute the condition it self.

 

 

 

 

 

 

<html>

<head>

     <title>getProperty</title>

</head>

   <body bg color=“#D4E0DF”>

      <formaction=“JavaExampleJSP_getProperty.jsp” method=“get”>

        <tablecellpadding=“2px” cellspacing=“1px” bgcolor=“#f7f9fb” width=“400px“align=“center”>

           <tr>

               <tdalign=“center” colspan=“2“>

                 <spanclass=“text”><h2>Employye’s Info</h2></span></td>

           </tr>         

           <tr>

              <tdalign=“center” width=“60%”>Enter Employee Name: <inputtype=“text” name=“nm” maxlength=“40“/></td>

           </tr>

           <tr>

             <tdalign=“center” width=“60%”>Enter Employee’s Job: <inputtype=“text” name=“jb” maxlength=“40“/></td>

           </tr>

           <tr>

             <tdalign=“center” width=“60%”>Enter Employee’s Company: <inputtype=“text” name=“cm”    maxlength=“40“/></td>

           </tr>

           <tr>

              <td><center><inputtype=“submit” value=“submit” /></center></td>

           </tr>

       </table>

   </form>

</body>

</html>

 

       Employyes Info   

getProperty.jsp

<html> 
  <head>
      <title>&lt;getProperty&gt;Example In JSP</title>
 </head>
    <body bg color="#D4E0DF">
    <%
        String empName = request.getParameter("nm");
        String job = request.getParameter("jb");
        String company = request.getParameter("cm");
        If(empName != null)
         {
    %>
         <jsp:useBean id="wrkr" class="p2.emp" scope="request"/>
         <jsp:setProperty property="empName" value="<%=empName %>" name="wrkr"/>
         <jsp:setProperty property="job" value="<%=job %>" name="wrkr"/>
         <jsp:setProperty property="company" value="<%=company %>" name="wrkr"/>
         <h3 align="center">Employee Details are :</h3>
         <table cellpadding="2px" bgcolor="#f7f9fb" width="400px"align="center">
   <tr>
         <td align="center">Employee Name: </td>
         <td align="center"><jsp:getProperty property="empName" name="wrkr"/></td>
   </tr>
   <tr>
         <td align="center">Employee Job: </td>
         <td align="center"><jsp:getProperty property="job" name="wrkr"/></td>
   </tr>
  <tr>
       <td align="center">Employee's Company: </td>
       <td align="center"><jsp:getProperty property="company" name="wrkr"/></td>
  </tr>
 </table>
     <%
   }
     %>
   </body>
   </html>
       
Emp.java
package p2;
public class emp
   {
        String empName;
        String job;
        String company;
        public String getEmpName()
         {
                return empName;
         }
                public void setEmpName(String empName)
        {
                this.empName = empName;
        }
                public String getJob()
        {
                return job;
        }
               public void setJob(String job)
        {
                this.job = job;
        }
              public String getCompany()
        {
                return company;
        }
               public void setCompany(String company)
        {
                this.company = company;
        }
}

Primary Sidebar

Java Server Pages

Java Server Pages

  • JSP - Home
  • JSP - Advantages
  • JSP - Architecture
  • JSP - Life Cycle
  • JSP - Servlet Disadvantages
  • JSP - PrintWriter Vs JspWriter
  • JSP - Session Tracking
  • JSP - Stateless Protocol
  • JSP - Hidden Form Fields
  • JSP - Program Structure
  • JSP - Bill Discount Program
  • JSP - Scripting Elements
  • JSP - fn:length()
  • JSP - fn:split()
  • JSP - fmt formatNumber Tag
  • JSP - Servlet Communication
  • JSP - fn:replace()
  • JSP - fmt:parseNumber Tag
  • JSP - fmt:parseDate Tag
  • JSP - fn:substring()

Other Links

  • JSP - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW