aspose file tools*
The moose likes JSP and the fly likes c:forEach in a form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "c:forEach in a form" Watch "c:forEach in a form" New topic
Author

c:forEach in a form

Brooke Maddox
Ranch Hand

Joined: Nov 23, 2012
Posts: 42
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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

Whether <c:forEach>, or any other JSP component, is used in a form or not is completely moot. Anything that's not a JSP mechanism is simply template text, and the JSP engine could care less what it is. It could be an HTML form, or the Gettysburg Address, or the result of your pet iguana walking across the keyboard.

What you need to make sure of is that the resulting HTML is valid. Yours is not. Why is the select element outside the form?

You must also create the HTML that does what you want. This is completely independent of JSP. So if you want the select element to participate in the form submission, it must inside the form and have a name.

And if you want the submitted value of the selected option to be something other than its display text, you must use the value attribute.

That's all just basic HTML concepts. Don;t get confused by the fact that the HTML is being generated by a JSP. In the end, it's just an HTML page like any other that is sent to the browser.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Brooke Maddox
Ranch Hand

Joined: Nov 23, 2012
Posts: 42
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: c:forEach in a form