How to display the selected value in dropdown from datastore using java GAE?

179 Views Asked by At

Am using the below code in jsp to retrieve the selected value from datastore. but the last option> value is displaying by default. whats wrong in this syntax?

option> value="Monthly" selected="<%=order.getPeriod()%> =='Monthly'? true:false">Monthly

option> value="Quaterly" selected="<%=order.getPeriod()%> =='Quaterly'?true:false">Quaterly

Someone kindly help me to findout. thanks in advance.

2

There are 2 best solutions below

5
On BEST ANSWER

It looks like you close the jsp tag in the wrong place. It should be:

<option value="Monthly" <%=order.getPeriod().equals("Quaterly")? selected : "" %>>Quaterly</option>
0
On

got the output i needed, the correct syntax is,

< option value="Yearly" <%=order.getPeriod().equals("Yearly")? "selected" : "" %>>Yearly

just delete the space in-between angular bracket and option.