JAVA AJAX教程第一章—初识AJAX
2009-10-27 00:00:00 来源:WEB开发网LoginAction.java代码如下:
package classmate;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class LoginAction_refersh extends HttpServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// TODO Auto-generated method stub
String uname = req.getParameter("uname");
String pwd = req.getParameter("pwd");
String target = "";
HttpSession session = req.getSession();
if(uname.equals("yhw")&&pwd.equals("admin")){
session.setAttribute("result", "ok");
target = "/ajaxtest/login.jsp";
}else{
session.setAttribute("result", "wrong");
target = "/ajaxtest/login.jsp";
}
resp.sendRedirect(target);
}
}
更多精彩
赞助商链接