views:

40

answers:

1

Kindly assist here, the getParameter is only printing the first portion of the String element in the tag.

here is the select tag

<select name="ActionSelect" id="ActionSelect" >
<%Iterator itr;%>
<% List data = (List) request.getAttribute("data");
   for (itr = data.iterator(); itr.hasNext();) {
     String value = (String) itr.next();
%>
<option value=<%=value%>><%=value%></option>
<%}%>
</select>

and here is the code in the servlet

PrintWriter pw = response.getWriter();
String connectionURL = "jdbc:mysql://localhost/db";
Connection connection;
try{
  this.ibrand = request.getParameter("ActionSelect");
  pw.println(ibrand);
} catch (Exception e) {
  pw.println(e);
}
+6  A: 

Use double quotes around value in the option tag:

<option value="<%=value%>"><%=value%></option>

As it is right now, you probably have a space in your value so only the part of the value before space is returned.

Incidentally, it's not necessary to declare the Iterator uptop; you can do so directly in the for loop:

for (Iterator itr = data.iterator(); itr.hasNext();) {

Finally, consider using tag libraries instead of writing java code directly as scriptlets in your JSP.

ChssPly76
Thanks that did it
Elijah