0
<select name="weatherStat" id="States">
<% 
			
			
			try {
			Connection connection = DataBaseConnectionManager.getConnection();
			String sqlQuery = "SELECT distinct state FROM ols_weather_current ORDER BY 1 asc";
			ResultSet rst2;
			PreparedStatement pstmt;
			pstmt = connection.prepareStatement(sqlQuery);
			rst2 = pstmt.executeQuery(sqlQuery);
			while (rst2.next ()) {
				
			<option value=rst2.getString("state")></option>
			}
			
			rst2.close();
            pstmt.close();
			} 
            
		catch (Exception e) {
			e.printStackTrace();
            }
	
	%>


</select>

having trouble...any suggestions?

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by Ezzaral
0

You just have your html and java code intermingled here and need to fix the tags

while (rst2.next ()) {
            %>
            <option value='<%= rst2.getString("state") %>'></option>
            <%
            }

            rst2.close();

or use out.write() to generate the html option tags instead.

(if jwenting pops in though he will tell you not to be using java in jsp pages at all, which is consistent with the current recommendations in JSP 2.0)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.