943,931 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Unsolved
  • Views: 1996
  • JSP RSS
Aug 30th, 2007
0

illegal start of expression & type

Expand Post »
java Syntax (Toggle Plain Text)
  1.  
  2. <select name="weatherStat" id="States">
  3. <%
  4.  
  5.  
  6. try {
  7. Connection connection = DataBaseConnectionManager.getConnection();
  8. String sqlQuery = "SELECT distinct state FROM ols_weather_current ORDER BY 1 asc";
  9. ResultSet rst2;
  10. PreparedStatement pstmt;
  11. pstmt = connection.prepareStatement(sqlQuery);
  12. rst2 = pstmt.executeQuery(sqlQuery);
  13. while (rst2.next ()) {
  14.  
  15. <option value=rst2.getString("state")></option>
  16. }
  17.  
  18. rst2.close();
  19. pstmt.close();
  20. }
  21.  
  22. catch (Exception e) {
  23. e.printStackTrace();
  24. }
  25.  
  26. %>
  27.  
  28.  
  29. </select>


having trouble...any suggestions?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
mimsc is offline Offline
70 posts
since Aug 2007
Aug 31st, 2007
0

Re: illegal start of expression & type

You just have your html and java code intermingled here and need to fix the tags
JSP Syntax (Toggle Plain Text)
  1. while (rst2.next ()) {
  2. %>
  3. <option value='<%= rst2.getString("state") %>'></option>
  4. <%
  5. }
  6.  
  7. 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)
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: generating dynamic/runtime query
Next Thread in JSP Forum Timeline: query to populate a drop-down





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC