Search code examples
javagoogle-app-enginedrop-down-menuselectedselectedvalue

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


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.


Solution

  • 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>