I am trying to show table value to JSP page but it not showing. I am trying it for one week.
product.java
This is model class of product
package com.practice.models;
public class Product {
private int id;
private String name;
private int qty;
private double price;
public Product(){}
public Product(int proId,String productName,int proQty,double proPrice){
this.id = proId;
this.name = productName;
this.qty = proQty;
this.price = proPrice;
}
public String getProductname() {
return name;
}
public void setProductname(String productname) {
this.name = productname;
}
public int getQty() {
return qty;
}
public void setQty(int qty) {
this.qty = qty;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
Struts.xml
<struts>
<package name="default" extends="struts-default">
<action name="checkonce" class="com.practice.controllers.GetProductList">
<result name="success">products.jsp</result>
<result name="error">error.jsp</result>
</action>
</package>
</struts>
GetProductList.java
I am Getting value from Database from DBtool class and I am getting all value successfully but values are not showing in the JSP file
public class GetProductList extends ActionSupport {
private static final long serialVersionUID = 1L;
private List<Product> productlist;
public List<Product> getproductlist(){
return productlist;
}
public void setproductlist(List<Product> productlist) {
this.productlist = productlist;
}
public String execute() throws IOException{
List<Product> productlist = new ArrayList<Product>();
try{
DBtool db = new DBtool();
System.out.println(1);
java.sql.ResultSet rs = db.getlist();
while(rs.next()){
int id = rs.getInt("id");
String proname = rs.getString("name");
int qty = rs.getInt("qty");
double price = rs.getDouble("price");
Product pro = new Product(id,proname,qty,price);
productlist.add(pro);
System.out.println(rs.getString("name"));
}
return SUCCESS;
}
catch(Exception ex){
System.out.println("Error : "+ex.getMessage());
return ERROR;
}
}
}
And This is products.jsp
<%# taglib uri="/struts-tags" prefix="s" %>
<table>
<thead>
<tr>
<th>Product ID</th>
<th>Product Name</th>
<th>Product Quantity</th>
<th>Product Price</th>
</tr>
</thead>
<tbody>
<s:iterator value="productlist" status="productlistStatus">
<tr>
<td><s:property value="id"/></td>
<td><s:property value="name"/></td>
<td><s:property value="qty"/></td>
<td><s:property value="price"/></td>
</tr>
</s:iterator>
</tbody>
</table>
productlist has the wrong scope in execute(). You declare it there again, so the scope of the variable is that method. You're not using the field. To solve it, remove the declaration in the execute() method, so it just says:
productlist = new ArrayList<>();
Also, Struts will be looking for a method getProductlist(). You should adapt the Java Bean naming convention.
Related
I'm using Spring with Thymeleaf template and when i'm trying to delete object in database using deleteById() method i'm encountering an error: org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'id' cannot be found on null. I cannot understand why its telling that "id" field is null, if in database i can see that "id" field isn't null. I can't figure out what is the problem... Help, please!
SOLUTION:
In the line <td th:text="${product.quantity}">Quantity</td></tr> in the file index.html i had excess , so i just needed to delete it.
Model class:
import javax.persistence.*;
#Entity
#Table (name = "product")
public class Product {
#Id
#GeneratedValue (strategy = GenerationType.IDENTITY)
private int id;
private String category;
private String brand;
private String model;
private Double price;
private Integer quantity;
public Product(){
}
public Product(String category, String brand, String model, Double price, Integer quantity) {
this.category = category;
this.brand = brand;
this.model = model;
this.price = price;
this.quantity = quantity;
}
public Product(int id, String category, String brand, String model, Double price, Integer quantity) {
this.id = id;
this.category = category;
this.brand = brand;
this.model = model;
this.price = price;
this.quantity = quantity;
}
#Override
public String toString() {
return "Product{" +
"id=" + id +
", category='" + category + '\'' +
", brand='" + brand + '\'' +
", model='" + model + '\'' +
", price='" + price + '\'' +
", quantity='" + quantity + '\'' +
'}';
}
public int getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
public Integer getQuantity() {
return quantity;
}
public void setQuantity(Integer quantity) {
this.quantity = quantity;
}
}
Controller:
package com.example.CRUDApp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
#org.springframework.stereotype.Controller
public class Controller {
private final ProductRepository productRepository;
#Autowired
public Controller(ProductRepository productRepository){
this.productRepository = productRepository;
}
#RequestMapping("/")
public String showAllProducts(Model model){
model.addAttribute("products", productRepository.findAll());
return "index";
}
#RequestMapping("/addProduct")
public String add(){
return "add-product";
}
#RequestMapping("/add")
public String addProduct(#RequestParam ("category") String category,
#RequestParam ("brand") String brand,
#RequestParam ("model") String model,
#RequestParam ("price") Double price,
#RequestParam ("quantity") Integer quantity,
Model mvcModel
) throws Exception {
Product product = new Product(category, brand, model, price, quantity);
productRepository.save(product); // save to database!!!
mvcModel.addAttribute("products", product);
return "index";
}
#RequestMapping("/delete")
public String delete(#RequestParam("id") Integer id, Model model) {
productRepository.deleteById(id);
model.addAttribute("products", productRepository.findAll());
return "index";
}
}
html file using Thymeleaf:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
<head>
<meta charset="UTF-8">
<title>Products</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<p align="center"><h2>Products</h2></p> <br>
<table class="table table-striped">
<tr><th>ID</th><th>Category</th><th>Brand</th><th>Model</th><th>Price, $</th><th>Quantity</th></tr>
<tr th:each="product: ${products}">
<td th:text="${product.id}">ID</td>
<td th:text="${product.category}">Category</td>
<td th:text="${product.brand}">Brand</td>
<td th:text="${product.model}">Model</td>
<td th:text="${product.price}">Price, $</td>
<td th:text="${product.quantity}">Quantity</td></tr>
<td><a href="#" th:href="#{/delete(id=${product.id})}" class="btn btn-danger">
<i class="fa fa-trash-o fa-lg" ></i>Delete</a></td>
</tr>
</table>
<center>
Add product
<br>
Refresh
</center>
</body>
</html>
In the line <td th:text="${product.quantity}">Quantity</td></tr> in the file index.html i had excess </tr> closing tag, so i just needed to delete it.
I want to add a picture to my table. but it does not appear on the page. I don’t get a single error. how can I specify the address of my image field in the index.html ?
the picture is uploaded to the database:
but not visible on page:
index.html
<body>
<div layout:fragment="content" class="py-5">
<div class="container">
<h2 style="text-align: center">Список ваших объявлений</h2>
<div class="col-md-12">
<table class="table">
<thead class="thead-light">
<tr>
<th>ID</th>
<th>Description</th>
<th>Price</th>
<th>Sold</th>
<th>Body</th>
<th>Brand</th>
<th>Engine</th>
<th>Model</th>
<th>Image</th>
</tr>
</thead>
<tbody>
<th:block th:each="order : ${orders}" th:remove="tag">
<tr>
<td th:text="${order.id}"></td>
<td th:text="${order.description}"></td>
<td th:text="${order.price}"></td>
<td th:text="${order.sold}"></td>
<td th:text="${order.body}"></td>
<td th:text="${order.brand}"></td>
<td th:text="${order.engine}"></td>
<td th:text="${order.model}"></td>
<td>
<a href="#" class="thumbnail">
<img th:src="#{/general/{id}/image(id = ${order.getId()})}" th:width="350" th:height="350"/>
</a>
</td>
</tr>
</th:block>
</tbody>
</table>
<p>
<a th:href="#{/general/showFormForAdd}" class="btn btn-outline-info btn-lg my-3">Новое объявление</a>
</p>
</div>
</div>
</div>
</body>
images located in Orders - byte[] image.
code below
#Entity #Table(name = "orders") public class Orders {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
#Column(name = "id")
private int id;
#Column(name = "description")
private String description;
#Column(name = "price")
private int price;
#Column(name = "sold")
private boolean sold;
#Column(name = "body")
private String body;
#Column(name = "brand")
private String brand;
#Column(name = "engine")
private String engine;
#Column(name = "model")
private String model;
#Lob
#Column(name = "image")
private byte[] image;
#Column(name = "str")
private String imageStr;
public Orders() {
}
public Orders(int id) {
this.id = id;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public boolean isSold() {
return sold;
}
public void setSold(boolean sold) {
this.sold = sold;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String getEngine() {
return engine;
}
public void setEngine(String engine) {
this.engine = engine;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public byte[] getImage() {
return image;
}
public void setImage(byte[] image) {
this.image = image;
}
public String getImageStr() {
return imageStr;
}
public void setImageStr(String imageStr) {
this.imageStr = imageStr;
} }
So you can do something like this
<img src="data:image/png;base64,${order.getImage()}">
i am learning spring mvc right now and I am facing with a question. I have two objects Country and Capital. What I am trying to accomplish is when I created an new country in the jsp I would like to create an new capital along with it (country name , population, and capital name will be enter by user). I am not sure how to retrieve the Capital object and how to pass it to my controllers. Please explain. Thanks!!
Country.java
#Entity
#Table(name="COUNTRY")
public class Country{
#Id
#Column(name="id")
#GeneratedValue(strategy=GenerationType.IDENTITY)
int id;
#Column(name="countryName")
String countryName;
#Column(name="population")
long population;
#OneToOne
#JoinColumn(name="capitalId")
Capital capital;
public Country() {
super();
}
public Country(int i, String countryName,long population) {
super();
this.id = i;
this.countryName = countryName;
this.population=population;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCountryName() {
return countryName;
}
public void setCountryName(String countryName) {
this.countryName = countryName;
}
public long getPopulation() {
return population;
}
public void setPopulation(long population) {
this.population = population;
}
public Capital getCapital() {
return capital;
}
public void setCapital(Capital capital) {
this.capital = capital;
}
}
Capital.java
#Entity
#Table(name="CAPITAL")
public class Capital {
#Id #GeneratedValue(strategy=GenerationType.IDENTITY)
#Column(name="id")
private int id;
#Column(name="capitalName")
private String capitalname;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCapitalname() {
return capitalname;
}
public void setCapitalname(String capitalname) {
this.capitalname = capitalname;
}
}
countryDetails.jsp
<form:form method="post" modelAttribute="country" action="/SpringMVCHibernateCRUDExample/addCountry">
<table>
<tr>
<th colspan="2">Add Country</th>
</tr>
<tr>
<form:hidden path="id" />
<td><form:label path="countryName">Country Name:</form:label></td>
<td><form:input path="countryName" size="30" maxlength="30"></form:input></td>
</tr>
<tr>
<td><form:label path="population">Population:</form:label></td>
<td><form:input path="population" size="30" maxlength="30"></form:input></td>
</tr>
<tr>
<td><form:label path="capital">Capital</form:label></td>
</tr>
<tr>
<td colspan="2"><input type="submit"
class="blue-button" /></td>
</tr>
</table>
</form:form>
Employee Pojo Class:
#Entity
#Table(name = "Employee")
public class Employee implements Serializable {
private static final long serialVersionUID = -723583058586873479L;
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
#Column(name = "empid")
private Integer empId;
#Column(name = "empname")
private String empName;
#Column(name = "empaddress")
private String empAddress;
#Column(name = "salary")
private Long salary;
#Column(name = "empAge")
private Integer empAge;
// .......................................................
#Column(name = "file_data")
private byte data;
public byte getData() {
return data;
}
public void setData(byte data) {
this.data = data;
}
// .......................................................
public Integer getEmpId() {
return empId;
}
public void setEmpId(Integer empId) {
this.empId = empId;
}
public String getEmpName() {
return empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
public String getEmpAddress() {
return empAddress;
}
public void setEmpAddress(String empAddress) {
this.empAddress = empAddress;
}
public Long getSalary() {
return salary;
}
public void setSalary(Long salary) {
this.salary = salary;
}
public Integer getEmpAge() {
return empAge;
}
public void setEmpAge(Integer empAge) {
this.empAge = empAge;
}
}
This is my Jsp Page :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Spring MVC Form Handling</title>
</head>
<body>
<h2>Add Employee Data</h2>
<form:form method="POST" action="/sdnext/save.html">
<table>
<tr>
<td><form:label path="id">Employee ID:</form:label></td>
<td><form:input path="id" value="${employee.id}" readonly="true"/></td>
</tr>
<tr>
<td><form:label path="name">Employee Name:</form:label></td>
<td><form:input path="name" value="${employee.name}"/></td>
</tr>
<tr>
<td><form:label path="age">Employee Age:</form:label></td>
<td><form:input path="age" value="${employee.age}"/></td>
</tr>
<tr>
<td><form:label path="salary">Employee Salary:</form:label></td>
<td><form:input path="salary" value="${employee.salary}"/></td>
</tr>
<tr>
<td><form:label path="address">Employee Address:</form:label></td>
<td><form:input path="address" value="${employee.address}"/></td>
</tr>
<tr>
<td><form:label path="data">Upload File:</form:label></td>
<td><form:input type="file" path="data" value="${employee.data}"/></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Submit"/></td>
</tr>
</table>
</form:form>
<c:if test="${!empty employees}">
<h2>List Employees</h2>
<table align="left" border="1">
<tr>
<th>Employee ID</th>
<th>Employee Name</th>
<th>Employee Age</th>
<th>Employee Salary</th>
<th>Employee Address</th>
<th>Employee Pic</th>
<th>Actions on Row</th>
</tr>
<c:forEach items="${employees}" var="employee">
<tr>
<td><c:out value="${employee.id}"/></td>
<td><c:out value="${employee.name}"/></td>
<td><c:out value="${employee.age}"/></td>
<td><c:out value="${employee.salary}"/></td>
<td><c:out value="${employee.address}"/></td>
<td><c:out value="${employee.address}"/></td>
<td><c:out value="${employee.data}"/></td>
<td align="center">Edit | Delete</td>
</tr>
</c:forEach>
</table>
</c:if>
</body>
</html>
This is my Controller Class:
#Controller
public class EmployeeController {
#Autowired
private EmployeeService employeeService;
#RequestMapping(value = "/save", method = RequestMethod.POST)
public ModelAndView saveEmployee(
#ModelAttribute("command") EmployeeBean employeeBean,
BindingResult result) {
Employee employee = prepareModel(employeeBean);
employeeService.addEmployee(employee);
return new ModelAndView("redirect:/add.html");
}
#RequestMapping(value = "/employees", method = RequestMethod.GET)
public ModelAndView listEmployees() {
Map<String, Object> model = new HashMap<String, Object>();
model.put("employees",
prepareListofBean(employeeService.listEmployeess()));
return new ModelAndView("employeesList", model);
}
#RequestMapping(value = "/add", method = RequestMethod.GET)
public ModelAndView addEmployee(
#ModelAttribute("command") EmployeeBean employeeBean,
BindingResult result) {
Map<String, Object> model = new HashMap<String, Object>();
model.put("employees",
prepareListofBean(employeeService.listEmployeess()));
return new ModelAndView("addEmployee", model);
}
#RequestMapping(value = "/search", method = RequestMethod.GET)
public ModelAndView SearchEmployee(
#ModelAttribute("command") EmployeeBean employeeBean,
BindingResult result) {
Map<String, Object> model = new HashMap<String, Object>();
model.put("employee", prepareEmployeeBean(employeeService
.getEmployeebyName("Sunil Kumar")));
// model.put("employee", prepareEmployeeBean(employeeService
// .getEmployeebyName(employeeBean.getName())));
model.put("employees",
prepareListofBean(employeeService.GetRowEmployeess1()));
return new ModelAndView("SearchEmp", model);
}
#RequestMapping(value = "/index", method = RequestMethod.GET)
public ModelAndView welcome() {
return new ModelAndView("index");
}
#RequestMapping(value = "/delete", method = RequestMethod.GET)
public ModelAndView editEmployee(
#ModelAttribute("command") EmployeeBean employeeBean,
BindingResult result) {
employeeService.deleteEmployee(prepareModel(employeeBean));
Map<String, Object> model = new HashMap<String, Object>();
model.put("employee", null);
model.put("employees",
prepareListofBean(employeeService.listEmployeess()));
return new ModelAndView("addEmployee", model);
}
#RequestMapping(value = "/edit", method = RequestMethod.GET)
public ModelAndView deleteEmployee(
#ModelAttribute("command") EmployeeBean employeeBean,
BindingResult result) {
Map<String, Object> model = new HashMap<String, Object>();
model.put("employee", prepareEmployeeBean(employeeService
.getEmployee(employeeBean.getId())));
model.put("employees",
prepareListofBean(employeeService.listEmployeess()));
return new ModelAndView("addEmployee", model);
}
private Employee prepareModel(EmployeeBean employeeBean) {
Employee employee = new Employee();
employee.setEmpAddress(employeeBean.getAddress());
employee.setEmpAge(employeeBean.getAge());
employee.setEmpName(employeeBean.getName());
employee.setSalary(employeeBean.getSalary());
employee.setEmpId(employeeBean.getId());
employeeBean.setId(null);
return employee;
}
private List<EmployeeBean> prepareListofBean(List<Employee> employees) {
List<EmployeeBean> beans = null;
if (employees != null && !employees.isEmpty()) {
beans = new ArrayList<EmployeeBean>();
EmployeeBean bean = null;
for (Employee employee : employees) {
bean = new EmployeeBean();
bean.setName(employee.getEmpName());
bean.setId(employee.getEmpId());
bean.setAddress(employee.getEmpAddress());
bean.setSalary(employee.getSalary());
bean.setAge(employee.getEmpAge());
bean.setData(employee.getData());
beans.add(bean);
}
}
return beans;
}
public EmployeeBean getEmployeenamesa(Employee employee) {
EmployeeBean bean = new EmployeeBean();
bean.setName(employee.getEmpName());
bean.setId(employee.getEmpId());
bean.setAddress(employee.getEmpAddress());
bean.setSalary(employee.getSalary());
bean.setAge(employee.getEmpAge());
bean.setData(employee.getData());
return bean;
}
private EmployeeBean prepareEmployeeBean(Employee employee) {
EmployeeBean bean = new EmployeeBean();
bean.setAddress(employee.getEmpAddress());
bean.setAge(employee.getEmpAge());
bean.setName(employee.getEmpName());
bean.setSalary(employee.getSalary());
bean.setData(employee.getData());
bean.setId(employee.getEmpId());
return bean;
}
}
This is my Employee Bean class :
public class EmployeeBean {
private Integer id;
private String name;
private Integer age;
private Long salary;
private String address;
// ........................................................
private byte data;
public byte getData() {
return data;
}
public void setData(byte data) {
this.data = data;
}
// .......................................................
public Long getSalary() {
return salary;
}
public void setSalary(Long salary) {
this.salary = salary;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
I am trying to add image in Data Base i have field file_data why longblob but when i try to get file from my local machine and try to upload image then i am getting null Can not set byte field Employee.data to null value i don't know where am doing mistake while i have set all value if we remove data from file then i am able to save data and get data from database i am having Problem only with file part please suggest me where am doing wrong
You cannot have a byte for the File upload. You need to use the MultipartFile/byte[] for that.
Refer this link for more info .
Using Multipart : http://www.ioncannon.net/programming/975/spring-3-file-upload-example/
For JPA entity, you need to annotate with #Lob annotation
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>