[英]How to use request.getparameter and response.redirect in jsp file to return username and password to JAVA CLASS
我绝对不是java的新手。我有JSP登录页面。现在我想在JAVA CLASS中验证用户名和密码(硬编码),而不是servelet等。 如何通过jsp执行此操作我的代码:
package FileIO;
public class Login_Authentication {
String username;
String password;
public String execute()
{
if(this.username.equals("buyer")
&& this.password.equals("buyPW"))
{
return "1";
}else
{
return "-1";
}
}
public String getUsername()
{ return username;
}
public void setUsername(String username)
{
this.username = username;
}
public String getPassword()
{ return password;
}
public void setPassword(String password)
{this.password = password;
}
}
you can add follow code in jsp page everywhere(import you package first)
{
<%
Login_Authentication auth = new Login_Authentication();
int result = auth.execute();
out.println(result == 1 ? "you login success" : "login fail!");
%>
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.