• 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 » Tags » Jsp getProperty Example
Next →
← Prev

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;
        }
}

You’ll also like:

  1. Jsp appletPlugin Example
  2. jsp:useBean tag Example
  3. JSP Forward Action Tag Example
  4. What is JSP?
  5. Architecture of JSP
Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


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 © 2023. All Rights Reserved.