I'm here again asking a question, I've tried asking this a while ago (for today) but I've reconstructed my code. So, my problem is that when I click the button to show the details from the database, it show me an error that Property Not Found, I'm confused as to why this error pops out, Here is an example of the error, as you can see it can read the elements in the database when I sysout it, displaying it in the console pic of error
)
//empServlet
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
empServices empserv= new empServices();
ArrayList <empGetSet> empgs = new ArrayList<empGetSet>();
if (request.getParameter("process")!=null && request.getParameter("process").equals("showdis")) {
empgs.addAll(empserv.getAll());
request.setAttribute("empdet", empgs);
RequestDispatcher rd = request.getRequestDispatcher("showdet.jsp"); //forward to xxxpage after submit by button
rd.forward(request,response);
}
//empServices
package emppackage;
import java.util.ArrayList;
public class empServices {
empServlet empservlet = new empServlet();
empDAO empdao = new empDAO();
public ArrayList <empGetSet> getAll()
{
return empdao.getAllEmp();
}
//empDAO
public ArrayList<empGetSet> getAllEmp()
{
ArrayList<empGetSet> empdetails = new ArrayList<empGetSet>();
try {
Connection conn = getConnection();
String showsql = "SELECT *FROM csemp;";
PreparedStatement psread= conn.prepareStatement(showsql);
ResultSet rsread = psread.executeQuery();
while (rsread.next())
{
empGetSet readgetset = new empGetSet();
readgetset.setFname(rsread.getString(1));
//System.out.println(readgetset.getFname());
System.out.println(rsread.getString(1));
readgetset.setLname(rsread.getString(2));
readgetset.setNameRes(rsread.getString(3));
readgetset.setSerials(rsread.getString(4));
readgetset.setJrss(rsread.getString(5));
readgetset.setBand(rsread.getString(6));
readgetset.setAcct(rsread.getString(7));
readgetset.setPMPs(rsread.getString(8));
readgetset.setsJRSS(rsread.getString(9));
readgetset.setOpenSeatDesc(rsread.getString(10));
readgetset.setReqSkills(rsread.getString(11));
readgetset.setReqBand(rsread.getString(12));
readgetset.setDreject(rsread.getString(13));
readgetset.setsRreject(rsread.getString(14));
readgetset.setDetActPlan(rsread.getString(15));
readgetset.setDataComplete(rsread.getString(16));
readgetset.setStat(rsread.getString(17));
empdetails.add(readgetset);
}
psread.close();
conn.close();
}
catch (Exception e)
{
e.printStackTrace();
}
return empdetails;
}
This is my Getters and Setters with really the same naming convention
package emppackage;
public class empGetSet {
private String Fname;
private String Lname;
private String NameRes;
private String Serials;
private String Jrss;
private String Band;
private String Acct;
private String PMPs;
private String sJRSS;
private String OpenSeatDesc;
private String ReqSkills;
private String ReqBand;
private String Dreject;
private String Rreject;
private String DetActPlan;
private String DataComplete;
private String Stat;
public String getFname() {
return Fname;
}
public void setFname(String Fname) {
this.Fname=Fname;
}
public String getLname() {
return Lname;
}
public void setLname(String Lname) {
this.Lname=Lname;
}
public String getNameRes() {
return NameRes;
}
public void setNameRes(String NameRes) {
this.NameRes=NameRes;
}
public String getSerials() {
return Serials;
}
public void setSerials(String Serials) {
this.Serials=Serials;
}
public String getJrss() {
return Jrss;
}
public void setJrss(String Jrss) {
this.Jrss=Jrss;
}
public String getBand() {
return Band;
}
public void setBand(String Band) {
this.Band=Band;
}
public String getAcct() {
return Acct;
}
public void setAcct(String Acct) {
this.Acct=Acct;
}
public String getPMPs() {
return PMPs;
}
public void setPMPs(String PMPs) {
this.PMPs=PMPs;
}
public String getsJRSS() {
return sJRSS;
}
public void setsJRSS(String sJRSS) {
this.sJRSS=sJRSS;
}
public String getOpenSeatDesc() {
return OpenSeatDesc;
}
public void setOpenSeatDesc(String OpenSeatDesc) {
this.OpenSeatDesc=OpenSeatDesc;
}
public String getReqSkills() {
return ReqSkills;
}
public void setReqSkills(String ReqSkills) {
this.ReqSkills=ReqSkills;
}
public String getReqBand() {
return ReqBand;
}
public void setReqBand(String Acct) {
this.Acct=Acct;
}
public String getDreject() {
return Dreject;
}
public void setDreject(String Dreject) {
this.Dreject=Dreject;
}
public String getRreject() {
return Rreject;
}
public void setsRreject(String Rreject) {
this.Rreject=Rreject;
}
public String getDetActPlan() {
return DetActPlan;
}
public void setDetActPlan(String DetActPlan) {
this.DetActPlan=DetActPlan;
}
public String getDataComplete() {
return DataComplete;
}
public void setDataComplete(String DataComplete) {
this.DataComplete=DataComplete;
}
public String getStat() {
return Stat;
}
public void setStat(String Stat) {
this.Stat=Stat;
}
}
This is my .jsp
<%# taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<!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>Show Details</title>
</head>
<body>
<div align="right"><button>Back</button></div>
<form action ="empServlet" method="get">
<table border =1 cellpadding="18">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Name of Resource (LN ID Format)</th>
<th>Serial Number</th>
<th>JRSS</th>
<th>Band</th>
<th>Account (Proposed)</th>
<th>PMP Seat</th>
<th>Seat JRSS</th>
<th>Open Seat Description</th>
<th>Required Skills</th>
<th>Required Band low/high</th>
<th>Date of Rejection</th>
<th>Reason for Rejection</th>
<th>Detailed Action Plan</th>
<th>Target Date of Completion</th>
<th>Status(Ongoing/Closed)</th>
<th colspan=2>Do This</th>
</tr>
</thead>
<tbody>
<c:forEach items ="${empdet}" var="empdet" >
<tr>
<td><c:out value ="${empdet.Fname}" /></td>
<td><c:out value ="${empdet.Lname}" /></td>
<td><c:out value ="${empdet.NameRes}" /></td>
<td><c:out value ="${empdet.Serials}" /></td>
<td><c:out value ="${empdet.Jrss}" /></td>
<td><c:out value ="${empdet.Band}" /></td>
<td><c:out value ="${empdet.Acct}" /></td>
<td><c:out value ="${empdet.PMPs}" /></td>
<td><c:out value ="${empdet.sJRSS}" /></td>
<td><c:out value ="${empdet.OpenSeatDesc}" /></td>
<td><c:out value ="${empdet.ReqSkills}" /></td>
<td><c:out value ="${empdet.ReqBand}" /></td>
<td><c:out value ="${empdet.Dreject}" /></td>
<td><c:out value ="${empdet.Rreject}" /></td>
<td><c:out value ="${empdet.DetActPlan}" /></td>
<td><c:out value ="${empdet.DataComplete}" /></td>
<td><c:out value ="${empdet.Stat}" /></td>
<td>Update</td>
<td>Delete</td>
</c:forEach>
</tbody>
</table>
<br>
Show All
</form>
</body>
</html>
Related
Here is my JSP page:
<c:url var="productSave" value="/admin/products/emi.html" />
<form:form method="Post" action="${productSave}"
modelAttribute="intrest">
<table>
<tr>
<td>Id :</td>
<td><form:input path="financerId" /></td>
</tr>
<tr>
<td>downpayment :</td>
<td><form:input path="downpayment" /></td>
</tr>
<tr>
<td>months :</td>
<td><form:input path="months" /></td>
</tr>
<tr>
<td>intrest :</td>
<td><form:input path="intrest" /></td>
</tr>
<tr>
<td></td>
<td><input onclick="self.close()" type="submit" value="Save" /></td>
</tr>
</table>
</form:form>
Here I am taking intrest field as double in model bean. but when i try to save the entity it throws
Failed to convert value of type 'java.lang.String' to required type 'com.salesmanager.core.model.catalog.product.relationship.FinancerRateofIntrest'; nested exception is org.springframework.core.convert.ConversionFailedException
Controller :
#RequestMapping(value = "/admin/products/emi.html", method = RequestMethod.POST)
public String GetEmiOption(#Valid #ModelAttribute("intrest") FinancerRateofIntrest intrest, Model model, HttpServletRequest request, HttpServletResponse response) throws Exception {
rateofintrest.save(intrest);
return "admin-products-emi";
}
Entity class:
#Entity
#Table(name = "FinancerRateofIntrest", schema = SchemaConstant.SALESMANAGER_SCHEMA)
public class FinancerRateofIntrest extends SalesManagerEntity<Long, FinancerRateofIntrest> {
/**
*
*/
private static final long serialVersionUID = 1L;
#Id
#Column(name = "ID", unique = true, nullable = false)
#TableGenerator(name = "TABLE_GEN", table = "SM_SEQUENCER", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT", pkColumnValue = "PRODUCT_RELATION_SEQ_NEXT_VAL")
#GeneratedValue(strategy = GenerationType.TABLE, generator = "TABLE_GEN")
private Long id;
private int financerId;
private String downpayment;
private String months;
private Double intrest;
public Double getIntrest() {
return intrest;
}
public void setIntrest(Double intrest) {
this.intrest = intrest;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public int getFinancerId() {
return financerId;
}
public void setFinancerId(int financerId) {
this.financerId = financerId;
}
public String getDownpayment() {
return downpayment;
}
public void setDownpayment(String downpayment) {
this.downpayment = downpayment;
}
public String getMonths() {
return months;
}
public void setMonths(String months) {
this.months = months;
}
}
You are using same name for object and variable inside it.
Change varibale name of modelAttribute from intrest to something else like financerRateofIntrest in :
<form:form method="Post" action="${productSave}" modelAttribute="financerRateofIntrest">
And
#RequestMapping(value = "/admin/products/emi.html", method = RequestMethod.POST)
public String GetEmiOption(#Valid #ModelAttribute("financerRateofIntrest") FinancerRateofIntrest intrest, Model model, HttpServletRequest request, HttpServletResponse response) throws Exception {
rateofintrest.save(intrest);
return "admin-products-emi";
}
Also, from controller method where you return your jsp page.
I'm trying to display all list of the employees in a table and also delete it at the same table. But this error keep bothering me. What could be its reason?
May 28, 2017 9:25:27 PM
org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
javax.el.PropertyNotFoundException: Property 'EmployeeID' not found on type bean.Employee
May 28, 2017 9:25:27 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [DisplayAllEmp] in context with path [/ELMS] threw exception [An exception occurred processing JSP page /elms/elms_skms/DeleteEmployeeAcc.jsp at line 55
52: <tbody>
53: <c:forEach items="${employee}" var="emp">
54: <tr>
55: <td><c:out value="${emp.EmployeeID}" /></td>
56: <td><c:out value="${emp.EmployeeIC}" /></td>
57: <td><c:out value="${emp.EmployeeName}" /></td>
58: <td><c:out value="${emp.EmployeePosition}" /></td>
Stacktrace:] with root cause
javax.el.PropertyNotFoundException: Property 'EmployeeID' not found on type bean.Employee
at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:266)
at javax.el.BeanELResolver$BeanProperties.access$300(BeanELResolver.java:243)
Here is my jsp page:
<div class="module-body table">
<form name = delete" method="POST" action="DeleteEmployeeServlet">
<table cellpadding="0" cellspacing="0" border="0" class="datatable-1 table
table-bordered table-striped display" width="50%">
<thead>
<tr>
<th>Employee ID</th>
<th>Employee IC</th>
<th>Employee Name</th>
<th>Employee Position</th>
<th>Employee Session</th>
<th>Employee Grade</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<c:forEach items="${employee}" var="emp">
<tr>
<td><c:out value="${emp.EmployeeID}" /></td>
<td><c:out value="${emp.EmployeeIC}" /></td>
<td><c:out value="${emp.EmployeeName}" /></td>
<td><c:out value="${emp.EmployeePosition}" /></td>
<td><c:out value="${emp.EmployeeSession}" /></td>
<td><c:out value="${emp.EmployeeGrade}" /></td>
<td><a href="DeleteEmployeeServlet?table=employee&employeeid=<c:out
value="${emp.EmployeeID}" />"onclick="return confirm('Are you
sure?');"><i class="icon-trash"></i></a> <br></td>
</c:forEach>
</tbody>
Here is my servlet page:
package servlet;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Date;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import model.EmployeeDAO;
import bean.Employee;
public class DeleteEmployeeServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private EmployeeDAO dao;
public DeleteEmployeeServlet() {
super();
dao = new EmployeeDAO();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String forward = "";
String table = request.getParameter("table");
if(table.equalsIgnoreCase("employee")){
int id = Integer.parseInt(request.getParameter("EmployeeID"));
dao.DeleteEmployeeDetails(id);
forward = "DisplayAllEmp?table=employee";
}
RequestDispatcher view = request.getRequestDispatcher(forward);
view.forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {}
}
Here is my model/DAO (viewEmployee):
public List<Employee> viewEmployee() {
List<Employee> employee = new ArrayList<Employee>();
try {
currentCon = ConnectionManager.getConnection();
stmt = currentCon.createStatement();
ResultSet rs = stmt.executeQuery("select * from employee");
while (rs.next()) {
Employee e = new Employee();
e.setEmployeeID(rs.getInt("EmployeeID"));
e.setEmployeePassword(rs.getString("EmployeePassword"));
e.setEmployeeName(rs.getString("EmployeeName"));
e.setEmployeeIC(rs.getString("EmployeeIC"));
e.setEmployeeGender(rs.getString("EmployeeGender"));
e.setEmployeeEmail(rs.getString("EmployeeEmail"));
e.setEmployeePhoneNo(rs.getString("EmployeePhoneNo"));
e.setEmployeeStreet1(rs.getString("EmployeeStreet1"));
e.setEmployeeStreet2(rs.getString("EmployeeStreet2"));
e.setEmployeePCode(rs.getInt("EmployeePCode"));
e.setEmployeeCity(rs.getString("EmployeeCity"));
e.setEmployeeState(rs.getString("EmployeeState"));
e.setEmployeeQualification(rs.getString("EmployeeQualification"));
e.setEmployeePosition(rs.getString("EmployeePosition"));
e.setEmployeeSession(rs.getString("EmployeeSession"));
e.setEmployeeGrade(rs.getInt("EmployeeGrade"));
e.setEmploymentDate(rs.getDate("EmploymentDate"));
employee.add(e);
System.out.println("Employee id: " + e.getEmployeeID());
}
System.out.println("All rows from table view Employee retrieved!");
} catch (SQLException e) {
System.out.println("Failed: An SQL Exception occured : " + e);
e.printStackTrace();
}
return employee;
}
Here is my DAO for DisplayAllEmp:
public void DeleteEmployeeDetails(int id) {
try {
currentCon = ConnectionManager.getConnection();
ps = currentCon.prepareStatement("delete from employee where employeeID=?");
// Parameters start with 1
ps.setInt(1, id);
ps.executeUpdate();
System.out.println("1 row of table Employee has been deleted. employeeID:" + id);
} catch (SQLException e) {
e.printStackTrace();
}
}
Here is my bean (Employee):
package bean;
import java.util.Date;
public class Employee {
private int EmployeeID;
private String EmployeePassword;
private String EmployeeName;
private String EmployeeIC;
private String EmployeeGender;
private String EmployeeEmail;
private String EmployeePhoneNo;
private String EmployeeStreet1;
private String EmployeeStreet2;
private int EmployeePCode;
private String EmployeeCity;
private String EmployeeState;
private String EmployeeQualification;
private String EmployeePosition;
private String EmployeeSession;
private int EmployeeGrade;
private Date EmploymentDate;
private boolean valid;
public Employee() {
EmployeeID = 0;
EmployeePassword = null;
EmployeeName=null;
EmployeeIC=null;
EmployeeGender=null;
EmployeeEmail=null;
EmployeePhoneNo=null;
EmployeeStreet1=null;
EmployeeStreet2=null;
EmployeePCode=0;
EmployeeCity=null;
EmployeeState=null;
EmployeeQualification=null;
EmployeePosition=null;
EmployeeSession=null;
EmployeeGrade=0;
EmploymentDate=null;
}
public Employee(int employeeID, String employeePassword, String employeeName, String employeeIC, String employeeGender, String employeeEmail, String employeePhone, String employeeStreet1, String employeeStreet2, int employeePCode, String employeeCity, String employeeState, String employeeQuaification, String employeePosition, String employeeSession, int employeeGrade, Date employmentDate) {
EmployeeID = employeeID;
EmployeePassword = employeePassword;
EmployeeName=employeeName;
EmployeeIC=employeeIC;
EmployeeGender=employeeGender;
EmployeeEmail=employeeEmail;
EmployeePhoneNo=employeePhone;
EmployeeStreet1=employeeStreet1;
EmployeeStreet2=employeeStreet2;
EmployeePCode=employeePCode;
EmployeeCity=employeeCity;
EmployeeState=employeeState;
EmployeeQualification=employeeQuaification;
EmployeePosition=employeePosition;
EmployeeSession=employeeSession;
EmployeeGrade=employeeGrade;
EmploymentDate=employmentDate;
}
public int getEmployeeID() {return EmployeeID;}
public void setEmployeeID(int employeeID) {EmployeeID = employeeID;}
public String getEmployeePassword() {return EmployeePassword;}
public void setEmployeePassword(String employeePassword) {EmployeePassword = employeePassword;}
public String getEmployeeName() {return EmployeeName;}
public void setEmployeeName(String employeeName) {EmployeeName = employeeName;}
public String getEmployeeIC() {return EmployeeIC;}
public void setEmployeeIC(String employeeIC) {EmployeeIC = employeeIC;}
public String getEmployeeGender() {return EmployeeGender;}
public void setEmployeeGender(String employeeGender) {EmployeeGender = employeeGender;}
public String getEmployeeEmail() {return EmployeeEmail;}
public void setEmployeeEmail(String employeeEmail) {EmployeeEmail = employeeEmail;}
public String getEmployeePhoneNo() {return EmployeePhoneNo;}
public void setEmployeePhoneNo(String employeePhoneNo) {EmployeePhoneNo = employeePhoneNo;}
public String getEmployeeStreet1() {return EmployeeStreet1;}
public void setEmployeeStreet1(String employeeStreet1) {EmployeeStreet1 = employeeStreet1;}
public String getEmployeeStreet2() {return EmployeeStreet2;}
public void setEmployeeStreet2(String employeeStreet2) {EmployeeStreet2 = employeeStreet2;}
public int getEmployeePCode() {return EmployeePCode;}
public void setEmployeePCode(int employeePCode) {EmployeePCode = employeePCode;}
public String getEmployeeCity() {return EmployeeCity;}
public void setEmployeeCity(String employeeCity) {EmployeeCity = employeeCity;}
public String getEmployeeState() {return EmployeeState;}
public void setEmployeeState(String employeeState) {EmployeeState = employeeState;}
public String getEmployeeQualification() {return EmployeeQualification;}
public void setEmployeeQualification(String employeeQualification) {EmployeeQualification = employeeQualification;}
public String getEmployeePosition() {return EmployeePosition;}
public void setEmployeePosition(String employeePosition) {EmployeePosition = employeePosition;}
public String getEmployeeSession() {return EmployeeSession;}
public void setEmployeeSession(String employeeSession) {EmployeeSession = employeeSession;}
public int getEmployeeGrade() {return EmployeeGrade;}
public void setEmployeeGrade(int employeeGrade) {EmployeeGrade = employeeGrade;}
public Date getEmploymentDate() {return EmploymentDate;}
public void setEmploymentDate(Date employmentDate) {EmploymentDate = employmentDate;}
public boolean isValid() {return valid;}
public void setValid(boolean valid) {this.valid = valid;}
}
Your Employee class has private fields only, hence you cannot access them using dot notation. The setters and getters are public and accessible outside of the class. Use them to retrieve the information you want in your jsp file.
Furthermore, take a look on the Oracle's documentation page Declaring Member Variables, section Access Modifiers.
public modifier—the field is accessible from all classes.
private modifier—the field is accessible only within its own class.
When you write ${emp.EmployeeID}, you are asking for a field named EmployeeID which has public access modifier, which does not exist.
This question already has answers here:
Show JDBC ResultSet in HTML in JSP page using MVC and DAO pattern
(6 answers)
Closed 7 years ago.
I am trying to show values from mysql table to a jsp table via servlet and I have done following
in BookSaleAuctionServlet
con = DriverManager.getConnection("jdbc:mysql://localhost/logins", "root", "");
try {
ArrayList<String> arr = new ArrayList<String>();
Statement stmt = con.createStatement();
ResultSet rst = stmt.executeQuery
("SELECT m.id,m.username,m.address,m.email,m.contact FROM members m");
request.setAttribute("memberList", rst);
request.getRequestDispatcher("MemberDetail.jsp").forward(request, response);
and in MemberDetail.jsp
<p>---------${memberList}</p>
<table border="1">
<thead>
<tr>
<th>Name</th>
<th>Address</th>
<th>Contact</th>
<th>Email</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<c:forEach var="row" items="${memberList}">
<tr>
<td><c:out value="${row.id}"/> </td>
<td><c:out value="${row}"></c:out> </td>
<td><c:out value="${row[0]}"></c:out> </td>
<td></td>
<td>Edit </td>
</tr>
</c:forEach>
</tbody>
</table>
Now i am not able to get values in the table and the value arriving from ${memberList} is com.mysql.jdbc.JDBC4ResultSet#166d6d3
I dont know how can i fetch value please help
Assume that you have a class User have the following attributes :-
class user{
private int id;
private String username;
private String address;
private String email;
private String contact;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getContact() {
return contact;
}
public void setContact(String contact) {
this.contact = contact;
}
}
In your servlet :-
ArrayList<user> member= new ArrayList<user>();
while(rst.next()) {
user myUser = new user();
myUser.setUsername(rst.getString("name"));
myUser.setId(rst.getInt("id");
myUser.setAddress(rst.getString("address"));
myUser.setEmail(rst.getString("email"));
myUser.setContact(rst.getString("contact"));
member.add(myUser);
}
request.setAttribute("memberList", member);
In your Jsp:-
<c:forEach var="row" items="${memberList}">
<tr>
<td><c:out value="${row.id}"/> </td>
<td><c:out value="${row.username}"></c:out> </td>
<td><c:out value="${row.address}"></c:out> </td>
<td><c:out value="${row.email}"></c:out> </td>
<td><c:out value="${row.contact}"></c:out> </td>
<td></td>
<td>Edit </td>
</tr>
</c:forEach>
Here is my java model class - CustomerProperty.java
package model;
import java.io.InputStream;
public class CustomerProperty {
public CustomerProperty() {
}
public int propertyid;
public String name;
public String phone;
public String occupation;
public String address1;
public String address2;
public String postcode;
public String city;
public String state;
public String payment;
public InputStream photo;
public String agent;
public String IDproject;
public String[] quickSale;
public String ICnumber;
public String bag;
public String mydate;
public int getPropertyid() {
return propertyid;
}
public void setPropertyid(int propertyid) {
this.propertyid = propertyid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getICnumber() {
return ICnumber;
}
public void setICnumber(String ICnumber) {
this.ICnumber = ICnumber;
}
public String getICNUMBER() {
return ICnumber;
}
public void setICNUMBER(String ICnumber) {
this.ICnumber = ICnumber;
}
public String getOccupation() {
return occupation;
}
public void setOccupation(String occupation) {
this.occupation = occupation;
}
public String getAddress1() {
return address1;
}
public void setAddress1(String address1) {
this.address1 = address1;
}
public String getAddress2() {
return address2;
}
public void setAddress2(String address2) {
this.address2 = address2;
}
public String getPostcode() {
return postcode;
}
public void setPostcode(String postcode) {
this.postcode = postcode;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getState() {
return state;
}
public void setState(String dateTime) {
this.state = dateTime;
}
public String getPayment() {
return payment;
}
public void setPayment(String payment) {
this.payment = payment;
}
public InputStream getPhoto() {
return photo;
}
public void setPhoto(InputStream photo) {
this.photo = photo;
}
public String getAgent() {
return agent;
}
public void setAgent(String agent) {
this.agent = agent;
}
public String getIDproject() {
return IDproject;
}
public void setIDproject(String IDproject) {
this.IDproject = IDproject;
}
public String[] getQuickSale() {
return quickSale;
}
public void setQuickSale(String[] quickSale) {
this.quickSale = quickSale;
}
public String getMyDate() {
return mydate;
}
public void setMyDate(String mydate) {
this.mydate = mydate;
}
Whenever my JSP calling this java class, it only can detect the original element. I have added a new element - mydate and it is like forever cannot detect it.
Below is the error code.
pe Exception report
messageInternal Server Error
descriptionThe server encountered an internal error that prevented it
from fulfilling this request.
exception
org.apache.jasper.JasperException: javax.el.PropertyNotFoundException:
The class 'model.CustomerProperty' does not have the property
'mydate'. root cause
javax.el.PropertyNotFoundException: The class 'model.CustomerProperty'
does not have the property 'mydate'. note The full stack traces of the
exception and its root causes are available in the GlassFish Server
Open Source Edition 4.0 logs.
I have try to delete the java class and recreate again but still, the JSP only can detect for my first 16 elements and not any new added element.
Any solutions? Thanks
Below is my JSP file code.
<head>
<title>Project Sales Report</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
</head>
<body>
<p align="center" style="font-family:times;font-size:40pt"><c:out value="${project2.projectName}"/> Sales Report</p>
<table align="center" bgcolor="silver" border="1" cellspacing="0" cellpadding="20" class="customer" >
<thead>
<tr>
<th>Unit ID</th>
<th>Agent</th>
<th>Customer Name</th>
<th>IC Number</th>
<th>Phone Number</th>
<th>Occupation</th>
<th>Address 1</th>
<th>Address 2</th>
<th>Postcode</th>
<th>City</th>
<th>State</th>
<th>Payment Type</th>
<th>Receipt</th>
</tr>
</thead>
<tbody>
<c:forEach items="${customerdetail}" var="abc">
<tr>
<td><c:out value="${abc.propertyid}"/></td>
<td><c:out value="${abc.agent}" /></td>
<td><c:out value="${abc.name}" /></td>
<td><c:out value="${abc.ICnumber}" /></td>
<td><c:out value="${abc.phone}" /></td>
<td><c:out value="${abc.occupation}" /></td>
<td><c:out value="${abc.address1}" /></td>
<td><c:out value="${abc.address2}" /></td>
<td><c:out value="${abc.postcode}" /></td>
<td><c:out value="${abc.city}" /></td>
<td><c:out value="${abc.mydate}" /></td>
<td><c:out value="${abc.payment}" /></td>
</tr>
</c:forEach>
</tbody>
</table>
<p> </p>
<div align="center">
<button type="button" style="width:70px;">Print</button>
<input type="button" value="Back" onClick="history.go(-1);
return true;" style="width:70px;"/>
</div>
</body>
Note your getter setters -
public String mybag() {
return mydate;
}
public void setmybag(String mydate) {
this.mydate = mydate;
}
It should be setMydate and getMydate. isn't it ?
Update -
It is case sensative.
public String mydate;
this should be
public String myDate;
Your JSP should be abc.myDate and not abc.mydate
<td><c:out value="${abc.mydate}" /></td>
I am displaying checkboxes on a page and want to only update values in the db for which the values were changed. Also I would like to display an error if nothing was changed and form was submitted.
This is what i have so far. Any suggestion?
View
public class PersonView {
private List<Person> personList;
public List<Person> getPersonList() {
return personList;
}
public void setPersonList(List<Person> personList) {
this.personList = personList;
}
}
Domain
public class Person {
private String fullName;
private Boolean isSupervisor;
private Boolean isManager;
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public Boolean isSupervisor() {
return isSupervisor;
}
public void setSupervisor(Boolean isSupervisor) {
this.isSupervisor = isSupervisor;
}
public Boolean isManager() {
return isManager;
}
public void setManager(Boolean isManager) {
this.isManager = isManager;
}
}
Controller
#Controller
#RequestMapping("/person.html")
public class PersonsController {
#Autowired
private PersonService personService;
#RequestMapping(method = RequestMethod.GET)
public String initForm() {
return "member";
}
#RequestMapping(method = RequestMethod.POST)
public String submitForm(#ModelAttribute PersonView personView) {
model.addAttribute("persons", personView);
return "successMember";
}
#ModelAttribute
public PersonView getPersonView(){
List<Person> persons= personService.getPersonList();
PersonView pv = new PersonView();
pv.setPersonList(persons);
return pv;
}
}
JSP
<html>
<title>Persons Information</title>
</head>
<body>
<form:form method="POST" modelAttribute="personView">
<table>
<tr>
<th>Full Name</th>
<th>Supervisor</th>
<th>Manager</th>
</tr>
<c:forEach var="person" items="${personView.personList}"
varStatus="row">
<tr>
<td>{person.fullName}</td>
<td><form:checkbox path="personList[row.index].supervisor" value="true" />
</td>
<td><form:checkbox path="personList[row.index].manager" value="true" />
</td>
</tr>
</c:forEach>
<tr>
<td><input type="submit" name="submit" value="Submit">
</td>
</tr>
<tr>
</table>
</form:form>
</body>
</html>