Hello! I'm new to the Code Ranch, but I've lurked around here a little. I have a couple of years' experience with
Java, but SQL/Struts2/HTML/Servlets/WEBSTUFFINGENERAL is all very new to me. I tried searching for the issue I'm having but it either isn't in here or I'm really awful at searching issues... probably the latter. I apologize in advance if I don't do a great job of explaining my issue and/or flood the page with code.
Anyway, I'm trying to make a
Struts application in Eclipse that works with a table in a database I have on MySQL. What I want it to do is allow a user to submit what they think about something, and then display everything that has been entered in the past. I guess it works somewhat like a comment section.
To better illustrate what I mean: Someone submits saying that the cat on the index page is "cute." On the resultant page, it should display only "cute" since they are the first to state anything. They go back to the index page and submit that the cat is "totally rad." On the resultant page, it should display "cute" followed by "totally rad" on the next line.
I've been basing my execute() function off of
this tutorial, but it doesn't seem like it covers inserting data, so I modified it. I think this could be the main issue. I'm not 100% sure what I'm doing or what's going on in some of the lines.
I've narrowed down where the issue is, but I'm not sure how to fix it. In short, my main issue is in my HelloWorldAction.java, with the statement "
ps.setString(1, newCompliment);"
Also, I apologize for the poor file names. I didn't want to mess things up just because I had filenames wrong, so I kept them in line with what I had in previous Struts2 tutorials.
Here is my file structure:
Files:
HelloWorldAction.java
struts.xml:
web.xml:
AccessDenied.jsp:
HelloWorld.jsp - This is the intended result. I want it to print out the ArrayList<
String> of previous responses.
index.jsp:
For learning MySQL, I've been using
this site along with the sample database they provided. In that sample database, I made a new table called "compliments" to be used in the above application.
Thank you so so much in advance for any and all help!!!