就高手解错 明天就要交啦
代码:
package myservlet.control;
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import mybean.data.Login;
import mybean.data.Password;
public class HandlePassword extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session=request.getSession(true);
Login login=(Login)session.getAttribute("Login");
boolean ok=true;
if(login==null){
ok=false;
response.sendRedirect("Login.jsp");
}
if(ok==true){
continueWork(request, response,login);
}
}
public void continueWork(HttpServletRequest request, HttpServletResponse response,Login login)
throws ServletException, IOException {
//HttpSession session=request.getSession(true);
//Login login=(Login)session.getAttribute("Login");
Connection con=null;
String logname=login.getLogname();
Password passwordBean=new Password();
request.setAttribute("password", passwordBean);
String oldPassword=request.getParameter("oldPassword");
String newPassword=request.getParameter("newPassword");
String uril="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=Friend";
try{
con=(Connection) DriverManager.getConnection(uril,"sa","123456");
Statement sql= con.createStatement();
ResultSet rs=sql.executeQuery("select* from member where logname='"+logname+"' and password='"+oldPassword+"'");
if(rs.next()){
String updateString="update member set password='"+newPassword+"'where logname='"+logname+"'";
int m=sql.executeUpdate(updateString);//数据能更新成功
if(m==1){
passwordBean.setBackNews("密码更新成功!");
passwordBean.setOldPassword(oldPassword);
passwordBean.setNewPassword(newPassword);
}
else{
passwordBean.setBackNews("密码更新失败!");
}
}
else{
passwordBean.setBackNews("密码更新失败!");
}
}catch (Exception e) {
passwordBean.setBackNews("密码更新失败!"+e);
}
RequestDispatcher disptcher=request.getRequestDispatcher("showNewPassword.jsp");
disptcher.forward(request, response);
}
public void init(ServletConfig config) throws ServletException {
super.init(config);
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}catch (Exception e) {}
}
}
错误:
HTTP Status 500 -
--------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /showNewPassword.jsp (line: 3, column: 0) Illegal value of scope attribute: requet (must be one of "page", "request", "session", or "application")
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:408)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:149)
org.apache.jasper.compiler.JspUtil.checkScope(JspUtil.java:102)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:622)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1182)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
org.apache.jasper.compiler.Node$Root.accept(Node.java:475)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1790)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:217)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
myservlet.control.HandlePassword.continueWork(HandlePassword.java:101)
myservlet.control.HandlePassword.doPost(HandlePassword.java:61)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.26 logs.
--------------------------------------------
Apache Tomcat/7.0.26
求高手解决啊
小弟刚加入没多少分 高手莫怪 小弟这里谢啦
[解决办法]
ResultSet rs=sql.executeQuery("select * from member where logname='"+logname+"' and password='"+oldPassword+"'");
if(rs.next()){
String updateString="update member set password='"+newPassword+"' where logname='"+logname+"'";
[解决办法]
org.apache.jasper.JasperException: /showNewPassword.jsp (line: 3, column: 0) Illegal value of scope attribute: requet (must be one of "page", "request", "session", or "application")
这个jsp中有错,就是你的request写错了,不是requet而是request,LZ太粗心了。