troubleshooting Question

Insert blank lines in arraylist

Avatar of aseshu70
aseshu70 asked on
JSP
2 Comments1 Solution391 ViewsLast Modified:
i have a java class which returns arraylist. I am using that arraylist in my jsp to show the results in drop down list. But i want to show blank line in first row of drop down. Here is my piece of code.

<SELECT NAME = "mylist" id="mylist" onchange="change

('GetList','hide');">

<%
  GetData gd=new GetData();
  ArrayList al = gd.GetData();
  al.add(" ");
 
  for (int i=0;i<al.size();i++)
  {
   
%>
<option><%=al.get(i)%></option>

<%}%>
</select>

In al.add it is inserting only at the end of drop down list, but i need in first row.
Pls help.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros