File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes JSP form Not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "JSP form Not working" Watch "JSP form Not working" New topic

JSP form Not working

Brooke Maddox
Ranch Hand

Joined: Nov 23, 2012
Posts: 42
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

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13024
//Change paramters to correct types
int id = Integer.parseInt(ID);

If this was my problem I would be:
1. examining the html on the browser with view source
2. logging that ID value and probably I would be catching NumberFormatExceptions.

Brooke Maddox
Ranch Hand

Joined: Nov 23, 2012
Posts: 42
Another rookie mistake on my part I had an extra form above my table.
I agree. Here's the link:
subject: JSP form Not working
It's not a secret anymore!