Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow