This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!

Brooke Maddox

Ranch Hand
+ Follow
since Nov 23, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Brooke Maddox

Another rookie mistake on my part I had an extra form above my table.
6 years ago
I have a JSP page that has a table that list each movie in my database. The user should be able to choose one movie from the list for purchase. I am using a form inside my table that has a hidden input and uses the Movie ID number as a parameter. The Servlet takes the parameter and sets it to the session, and sends the response to another JSP page. Everything works fine, unless I choose the first item in the table. So for instance, I have 5 movies in my database, if I choose to purchase the first one my cart.jsp page is empty but if I choose any of the other 4 the cart.jsp page displays the movie ID and Movie title.
Here is my code




6 years ago
I would also like to thank you for all your help, these forums have taught me 10X more than what my instructor has. So thank you.
6 years ago
JSP
I am using a select list in my form where the user can choose an item from the list and I want the parameter to be the ID number of their selection. Am I doing this correctly? When I print out my the parameter in my servlet it comes back null.
6 years ago
JSP
I figured it out, thanks for your help. My text file had a line break between lines.
6 years ago
Here is the contents of my text file
1 Say Anything Drama 5.95 10
2 Water for Elephants Drama 6.95 6
3 Duplicity Comedy 8.95 10
4 Bad Teacher Comedy 6.95 5
5 Finding Nemo Family 10.95 9

6 years ago
Okay I thought I figured out how to parse the string into its component parts but then something happened and now I keep getting this Exception. Not sure what I changed that caused this but I can't figure out what it is.

I keep getting java.lang.ArrayIndexOutOfBoundsException: 1
Here is my new while loop

6 years ago
I need the jsp page to only display movie.title and then use the movie's id # to get more information about the movie. So my text file has something like
1 Say Anything Drama 5.95 10
2 Water for Elephants Drama 14.95 10
3 Duplicity Comedy 8.95 10

I would like my JSP page to display a list of the movies such as
Say Anything
Water For Elephants
Duplicity
The user should be able to choose a movie from the list and upon hitting the submit button see the rest of the details about the movie they choose. For example if the user choose Say Anything from the list
the next view would display a table
Movie ID: 2
Title: Water for Elephants
Genre: Drama
Price: 5.95
Qty: 10

As of right now my the c:for each statement in myfirst jsp page is displaying the entire contents of the ArrayList such as:
1 Say Anything Drama 5.95 10
2 Water for Elephants Drama 14.95 10
3 Duplicity Comedy 8.95 10

How can I get it to display only the movie Titles.
I noticed my servlet code wasn't added
6 years ago
I am having trouble understanding how my ArrayList works. I have a method that reads from a text file and puts the contents into an ArrayList<Movie> the Class returns the ArrayList. I have called the method in my Servlet and set the returned ArrayList to another ArrayList<Movie>. I have then set this ArrayList to the session, and used c:forEach to retrieve it in my JSP. What I have as of right now works, my problem is that it is returning the entire ArrayList to my JSP. Do I need to get the contents of the ArrayList and set them to my object in the servlet and then set the object to the session?
GetMovie():


Servlet:

JSP:
6 years ago
I got it! Thanks again Bear
6 years ago
Thank you Tim :)
6 years ago
JSF
So do you suggest that I have a folder outside the WEB-INF that is dedicated to my .txt file? Can I put the .txt file in the same folder as my Bean or Class? Do I still need to use the getServletContext() in my Servlet?
6 years ago
For my assignment I have to use a text file that I can read from and write to. I thought that putting it in the WEB-INF would keep it hidden from the user.
6 years ago
I have a method in a Java class that I would like to use to write to a text file which is located in my WEB-INF dir. I think I am having trouble getting the correct path for this file. I am calling the method in my Servlet and using Servlet Context in order to get the path but I have yet to write anything to the text file. Here is my code
Servlet

Class
6 years ago