JSP ComboBox

Hi I have jsp that have a combo box with 3 options,


I,m sending some values of a DB to that JSP. I have a column that need to match that JSP comboBox.

Let said that in the database the user save the value Option2, i want to fill the ComboBox with the value that is in the database, but i also want that the user have the oportunity to choose one of the 2 others options.

If need more details let me know
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I am not sure I understand what problem you do have exactly...
Pramod KumarCommented:
Try this:
	//reading data from db
	String fromDB = request.getAttribute("fromDB");

<select name="city">
	<%if (fromDB.equals("Option1")) {%>
		<option selected value="Option1" selected>Option1</option>
		<option selected value="Option1">Option1</option>

	<%if (fromDB.equals("Option2")) {%>
		<option selected value="Option2" selected>Option2</option>
		<option selected value="Option2">Option2</option>

	<%if (fromDB.equals("Option3")) {%>
		<option selected value="Option3" selected>Option3</option>
		<option selected value="Option3">Option3</option>


Open in new window

cano63Author Commented:
I founf it

<option value="financial" <%= auto.getFinancigMethod().equalsIgnoreCase("financial")?" selected":""%>>Financial</option>
Thanks a lot

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.