tags:

views:

22

answers:

1

Hi All, I have the following data

   <select  class="small" name="test"><option  value="1">a</option>

i want to print 'a' how can i do it? request.getparameter(test) gives me the selected value like 1

+2  A: 

You can't, at least not this way.

The general flow is this

  1. You have some model, containing both values (let's call them "value" and "display value")
  2. You output the <select> in a jsp and iterate over that model
  3. When the form is submitted back to the servlet/jsp, you get the "value" and, based on your model, get the corresponding "display value"

As pointed out in the comment below, the most widely used model is a Map implementation. TreeMap. HashMap, LinkedHashMap, depending on your data.

Bozho
+1. Yup, and you can use `Map` to be your model, a further hint :)
Adeel Ansari