General syntex of JSP setProperty Tag look like this:
Syntax:
<jsp:setProperty name="xyz" > The code include a package bean , we have a class Employees. The employee class include a string variable first name, last name and address. Inside the class we have a setter and getter method. 1. set XXX ( ): This method hold the value of the parameter by the implementor of interface. 2. get XXX( ): This method retrieve the value of the parameter set in the setXXX () method. The JSP page uses this getter and setter method. <jsp:useBean> - 1. The < jsp:use Bean> instantiate a bean class and locate a bean class with specific scope and name.
package com.dineshonjava.bean;
/**
* @author Dinesh Rajput
*
*/
public class Employee {
private String firstName;
private String lastName;
private String address;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
index.jsp
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<html>
<body>
<h1>Employee Form Bean Value</h1>
<jsp:useBean id="emp" class="com.dineshonjava.bean.Employee" scope="page" /><jsp:setProperty name="emp" >
Copy myapp folder on webapp directory of tomcat at
C:Program Files (x86)Apache Software FoundationTomcat 7.0webappsand restart server and hit the following URL
http://localhost:8080/myapp/index.jsp
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…