This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Consider my scenario:
In the JSP, I have a field named 'gender' with male, female as values. In the DB, I want to save it as 'M' or 'F' if the selected name is male or female respectively.
When I retrieve this value from DB, I want to check in my JSP; if the value is 'M', the select box in JSP should show the value as 'Male'. 'Female' otherwise. So, I have written the following if condition in JSP.
If you are using struts, then why don't you try the struts select tag with a map of properties like this
Using this you'll not need any condition or anything. I think you'll iterate over a collection or have a single object of User or whatever class in your action so the gender property will automatically be taken from the value stack...