Here is the page I need to display it in:
The ProductIO page handles the filepath information and saves it into a product.
Here is the Product class
Here is my Servlet.
So here's the key error message out of that stack trace:
javax.el.PropertyNotFoundException: Property 'code' not found on type java.lang.String
Okay, so let's find out where you used the 'code' property in your EL... Here it is:
So the JSP compiler thinks that 'item' is a String, and why is that? Looks like you meant for it to be a Product, but it's a String. Let's see how it gets to be a String, by finding where it's declared... Here's where you do that:
So yeah, that's a String expression. You meant for it to be an EL expression which took the "product" attribute and extracted its "items" property, but you missed one small thing. Can you see what it is?
You seem to be reading the 'displayProducts' attribute from the session, doing nothing with it, then creating a new Product, setting its values based on the request parameters, then sticking this new Product back into the session as the 'displayProducts' attribute.
I think you need to step back a bit and write down the flow you think should be happening to give you the correct data for the JSP to process.
One thing, though. you should probably be putting this data in the request object, not the session.
It doesn't look like session data to me.
Junilu Lacar wrote:Do you anticipate having more than one concurrent user for this? Because if you do, then you're in for a world of hurt by writing your ProductIO class like that. You have mutable static fields and that's generally not a good idea, especially in a web application.
No. It's a basic crud system. Just need to write and read from the io class.
Here is my updated Servlet
Here is my form in the addProduct.jsp (also will be update)
The problem I am facing is that it wants to goto /add and not add the items in ProductIO and then back to displayProduct