Well . this is fairly a simple question. Lets say i have a registration form, some user has registered and i have the details in my database.

Now i can use the same form for letting the user edit his profile. I can prefill the textboxes by giving the following example

<input type="text" value="<%= some_userbean.getname() %>"  />

the problem is how to make an option of <select> marked as selected. i have it value in my database. Can this be done in JSP without using javascript. My selection menu in the form is static

<%
String init= "3";
%>

<select name="dropDown">
  <option value="1" <%= ( "1".equals(init) )?"selected":"" %> >One</option>
  <option value="2" <%= ( "2".equals(init) )?"selected":"" %> >Two</option>
  <option value="3" <%= ( "3".equals(init) )?"selected":"" %> >Three</option>
  <option value="4" <%= ( "4".equals(init) )?"selected":"" %> >Four</option>
  <option value="5" <%= ( "5".equals(init) )?"selected":"" %> >Five</option>
</select>

Although it is better to use a for loop for these things (<select>)

thanks. I know loops would be better...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.