在下面那段代码中
6. <%
7. Connection conn = null;
8. try {
9.  conn = DBConnection.getConnection();
10. PreparedStatement pStat = conn.prepareStatement(
11.  "select USER_NAME from T_USER where USER_ID=? and password = ?");
12. pStat.setString(1, userBean.getUserId());
13. pStat.setString(2, userBean.getPassword());
14. ResultSet rs = pStat.executeQuery();
15. if (rs.next()) { //密码正确
16.  userBean.setUserName(rs.getString(1));//设置用户名
17.  session.setAttribute("ses_userBean", userBean);//将userBean放入Session对象中
18. %><jsp:forward page=" welcome.jsp "></jsp:forward>
19. <%} else { //密码错误%>
20. <jsp:forward page="fail.jsp"></jsp:forward>
21. <%
22.  }} finally {
23.   if(conn != null) conn.close();
24.  }
25. %>
我想问的是:
1 里面的第19行 <%} else { //密码错误%> 为什么要在}else{前加入<% %>,能不加么?请大家解释一下,我刚刚学JSP
2 .if (rs.next()) { //密码正确 rs难道不是指向查询结果中的第一条记录么?为什么是下一条不为空才是密码正确呢?