Reputation: 1
In my Jsp page, I am getting the error :
Cannot find any information on property 'productList' in a bean of type 'Smithd81.InventoryManager'
The InventoryManager class has a getProductList() method which returns a List of Product objects, which I need to access.
In my JSP:
<jsp:useBean id = "productManager" scope = "page" class = "Smithd81.InventoryManager" />
<jsp:getProperty name = "productManager" property = "productList" />
I thought I had this correct on the getProperty property name- starts in lower case and whatnot, which is the typical pitfall for this error, but I definitely have it spelled correctly.
Where I seem to get the error:
<c:forEach var="p" items="${productManager.productList}">
<div>
<form action="inventory" method="POST">
<label>
<span>UPC</span>
<input type="text" name="upc" value="${p.getUpc()}" readonly="readonly"/>
</label>
<label>
<span>Short Details</span>
<input type="text" name="shortDetails" value="${p.getShortDetails()}" />
</label>
<label>
<span>Long Details</span>
<input type="text" name="longDetails" value="${p.getLongDetails()}" />
</label>
<label>
<span>Price</span>
<input type="text" name="price" value="${p.getPrice()}" />
</label>
<label>
<span>Stock</span>
<input type="text" name="stock" value="${p.getStock()}" />
</label>
<input type="submit" name="button" value="Edit" />
<input type="submit" name="button" value="Delete" />
</form>
</div>
</c:forEach>
For clarification, Inside the InventoryManager Class, the method signature reads:
public static List getProductList() throws IOException, ClassNotFoundException {
try {
List<Product> productsList = new ArrayList<>(); //empty product list
Collection<Product> productsFromFile = CollectionFileStorageUtility.load(Product.class);//loads collection from file
productsList.addAll(productsFromFile);// adds all current products from file to the productList List.
return productsList;
} catch (IOException e) {
System.out.println("IOException: error accessing data file.");
return null;
} catch (ClassNotFoundException e) {
System.out.println("ClassNotFoundException: error accessing class.");
return null;
}
}
Upvotes: 0
Views: 360
Reputation: 1664
Refactor your package name to lowercase. Another case is that you are trying to call static method on object (your bean finally is object). So method getProductList()
should be non-static.
Upvotes: 1