[nobr]> i have taken two combobox in my code , and i want to
> select the value from combobox. please anyone can
> help me out.
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><title></title></head>
<body>
<form action="" method="post">
<fieldset>
<legend>My Combo Box Example:</legend>
<select name="myComboBox" multiple="multiple">
<option value="123">First Option</option>
<option value="456">Second Option</option>
<option value="789">Third Option</option>
</select>
<br/>
(Hint: Hold the Ctrl key to select multiple)
<br/><br/>
<input type="submit" name="submit" value="Submit This Form to Itself"/>
</fieldset>
</form>
<hr/>
<div>
<br/><br/>
Values Selected from the Combo Box are:<br/><br/>
<%
String[] myComboBoxValues = request.getParameterValues("myComboBox");
%>
<%
/*Short for loop syntax requires JDK 1.5 or higher*/
for (String myComboBox : myComboBoxValues) {
out.println(myComboBox);
out.println("<br/>");
}
%>
</div>
</body>
</html>
Note that I've use JSP Scriptlets for illustration purposes only. Now a better way to write JSPs is to use JSTL 1.1.x or higher tags.
Avoid Scriptlets , and use MVC framework , make use of Servlets and JavaBeans.[/nobr]