下面是我写的一个简单登录界面:用户名和密码都保存在文件中。总是出现异常说是37行有错,但是就是没有找到。。符号都是对的
异常:
type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Exception in JSP: /Login.jsp:3734: out.print(code+"<BR>");
35: out.print(usercode+"<BR>");
36:
37: if(username.equals(name)&&usercode.equals(code))
38: out.print("Log In Successly");
39: else
40: out.print("Log In Failed");代码:
<%@page contentType="text/html" import="java.io.*"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>简单的用户登录界面</title>
</head>
<body>
<form action="Login.jsp" method="post">
<table border="1" cellspacing="1" cellpadding="4" width="80%" align="center">
<tr bgcolor="pink"><td colspan="2"><font color="blue">会员登录</font></td></tr>
<tr><td width="21%">用户名:</td>
<td width="59"><input type="text" name="username"></td></tr>
<tr><td width="21%">密码:</td>
<td width="59"><input type="password" name="usercode"></td></tr>
</table>
<center><input type="submit" name="loginsubmit" value="会员登录"></center>
<% String username=request.getParameter("username");
String usercode=request.getParameter("usercode");
try{
File f=new File("E:\\users","student.txt");
FileReader in=new FileReader(f);
BufferedReader BufferIn=new BufferedReader(in);
String name="ok",code="ok";
while((name=BufferIn.readLine())!=null){
code=BufferIn.readLine();
out.print(name+"<BR>");
out.print(username+"<BR>");
out.print(code+"<BR>");
out.print(usercode+"<BR>");
if(username.equals(name)&&usercode.equals(code))
out.print("Log In Successly");
else
out.print("Log In Failed");
}
BufferIn.close();
in.close();
}catch(IOException ee){}%>
</form>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货