JSP制作动态网页,Tomcat预览时错误提示:

org.apache.jasper.JasperException:UnabletocompileclassforJSP:Anerroroccurredatline:8i... org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 8 in the jsp file: /checklogin.jsp
name cannot be resolved
5: <%
6: String username = request.getParameter("name");
7: String password = request.getParameter("password");
8: String sql ="select * from member where name='"+name+"' and password='"+password+"'";
9: Statement stmt=conn.createStatement();
10: ResultSet rs = stmt.executeQuery(sql);
11: if ("用户名正确".equals(s)){

An error occurred at line: 11 in the jsp file: /checklogin.jsp
s cannot be resolved
8: String sql ="select * from member where name='"+name+"' and password='"+password+"'";
9: Statement stmt=conn.createStatement();
10: ResultSet rs = stmt.executeQuery(sql);
11: if ("用户名正确".equals(s)){
12: session.setAttribute("name",name);
13: response.sendRedirect("re-index.html");
14: }else if (false){%>

An error occurred at line: 12 in the jsp file: /checklogin.jsp
name cannot be resolved
9: Statement stmt=conn.createStatement();
10: ResultSet rs = stmt.executeQuery(sql);
11: if ("用户名正确".equals(s)){
12: session.setAttribute("name",name);
13: response.sendRedirect("re-index.html");
14: }else if (false){%>
15: <%}else{%>

Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
希望能把这一段代码纠正...随时调试正确代码- -
展开
 我来答
editsad
2010-12-22 · TA获得超过456个赞
知道小有建树答主
回答量:94
采纳率:50%
帮助的人:54.3万
展开全部
改成
String name= request.getParameter("name");
String password = request.getParameter("password");
String sql ="select * from member where name='"+name+"' and password='"+password+"'";
Statement stmt=conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
if(rs!=null&&rs.next()){
session.setAttribute("name",name);
response.sendRedirect("re-index.html");
}else{
out.println("用户名或密码错误");
}

别的代码看不到了
zhangligai1988
2010-12-22 · TA获得超过280个赞
知道小有建树答主
回答量:99
采纳率:0%
帮助的人:71.5万
展开全部
第8行 找不到name变量 应该是username
第11行 找不到s变量 你反回的是ResultSet怎么能和字符串比较?
第12行 还是找不到name变量
难道这些在你写代码的时候myeclipse不报错误?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式