Originally posted by Scott Updike: I'm somewhat new to JSP coding as you'll see
Then here are a few comments and suggestions:
1) Move your Java logic out of the JSP page and into servlets and/or beans. This is escpecially true of JDBC code.
2) Why are you emitting HTML markup from Java? You're already in a JSP page. Building up markup in Java strings is just plain weird.
With regards to your issue. My next suggestion is to do a View Source of the page containing the buttons once it hits the browser to make sure that the HTML markup is well-formed and what you expect it to be.
Post it here (please use UBB code tags), if you like, for inspection. [ February 24, 2006: Message edited by: Bear Bibeault ]
You might also want to try the sample code I posted to see if it works as expected. If it does, that detemrines that the issue definitely lies with your page.
Joined: Feb 16, 2006
I'm getting fairly frustrated since it's preventing me from doing other things. I'm running WinXP, Tomcat 5.5. I promise this is a very basic environment! If it helps, I'm using the above JSP calling the following servlet:
Well, like I said before, I'm just starting to learn JSPs and "I am where I am" in the books. So far, they're still using HTML in the JSPs at this point.
The returned values via my JDBC connection are returning fine. It's only the buttons that I'm having trouble with. I can certainly move the JDBC code out of the JSP layer and back into the Servlet layer.
I did follow your advice and did a "view Source" on the web page and it looks fine (as far as I can tell):
It seems like the more you know, the more complicated sometimes...
If you just change the form method to GET instead of POST, you will see what parameters get attached to the url when form is submitted.
I guess the problem will be solved if you use the HTML 'input' element with type submit. In this case only the information of the button clicked will be attached to the form data when submitting even if the form has multiple submit buttons with the same name. While the 'Button' element you are struggling with has some advantages like decorating the button label more nicely, it was previously supported by Internet Explorer only (not sure other browsers now support it).
I didn't try but it looks like with the 'Button' element you can send multiple values associated with the same parameter name. In this case you can get all the values using request.getParameterValues("your_param_name") as you may already know.
Hope this helps. [ February 24, 2006: Message edited by: Heonkoo Lee ]