• Post Reply Bookmark Topic Watch Topic
  • New Topic

Make a table with a product maintenance crud system

 
Johnathon Anderson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to take a txt file that has product in it. the system reads the lines in the txt file, saves them to an array. i need to display the content in a table.

Here is the page I need to display it in:


The ProductIO page handles the filepath information and saves it into a product.
ProductIO


Here is the Product class


Here is my Servlet.

 
Johnathon Anderson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made some changes.

main page:


and I changed my servlet



I am getting this error.



PLEASE HELP
 
Paul Clapham
Sheriff
Posts: 21963
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Johnathon, welcome to the Ranch! It looks like you've been making pretty good progress on your own since you originally posted your question. I was going to say "First thing to do is to decide what HTML you're going to output" but it looks like you've done that already and continued on to set things up the right way. Only there's this little problem...

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?
 
Johnathon Anderson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
THANKS!!!



That seems to have fixed my errors. However, the page is blank, nothing is being displayed.

inside of my textfile, I have the following:

 
Johnathon Anderson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is an updated Servlet

 
Dave Tolls
Ranch Hand
Posts: 2369
25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't see anywhere in that servlet where you are getting a list of the products.
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.
 
Johnathon Anderson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The list of products are in the ProductIO class.

Would I do something like:
 
Johnathon Anderson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I cant seem to edit my post.....



This is what I have, but what do I do with the data once I get it.... and I would imagine I need to store it somewehre as well....or, I can setParameter with that string....
 
Dave Tolls
Ranch Hand
Posts: 2369
25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're still charging in.
You need to write down what that servlet is supposed to do when the request arrives.

There are issues with ProductIO anyway, but that secondary at the moment to the actual functionality of the servlet.
 
Johnathon Anderson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dave.

I was able to get everything to be pulling through from the txt file inside of a table. But my table was messing up.

I'll repost when I get home unless I fix it after messing around.
 
Junilu Lacar
Marshal
Posts: 10387
124
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Johnathon Anderson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Dave Tolls
Ranch Hand
Posts: 2369
25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But this is a webapp.
As soon as you have two people hitting the server at the same time you will hit issues (which is what I was eventually going to bring up).
 
Johnathon Anderson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:But this is a webapp.
As soon as you have two people hitting the server at the same time you will hit issues (which is what I was eventually going to bring up).


Yeah. It's to get my feet wet with servlets, JSP, etc.
Thanks for the heads up though!
 
Junilu Lacar
Marshal
Posts: 10387
124
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to get your feet wet, you shouldn't be doing it by carrying a load of rocks and stepping into quicksand. You can start small and still do it the right way.
 
Johnathon Anderson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, So I got it so everything will read from the file. Now, I need to set it up so I can add/update a list item....
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!