帮忙看下这个JSP页面为什么会报错,最后一行
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" isErrorPage="false"%>
<%@page import="java.security.MessageDigest"%>
<%!
private static final String KEY = ":cookie@helloweenvsfei.com";
public final static String calcMD5(String ss){
String s = ss==null?"":ss;
char hexDigits[] = {'0','1','2','3','4','5','6','7','8','9',
'a','b','c','d','e','f','g'};
try {
byte[] strTmp = s.getBytes();
MessageDigest mdTmp = MessageDigest.getInstance("MD5");
mdTmp.update(strTmp);
byte[] md = mdTmp.digest();
int j = md.length;
char str[] = new char[j*2];
int k = 0;
for(int i = 0; i< j; i++){
byte byte0 = md[i];
str[k++] = hexDigits[byte0 >>> 4 & 0xf];
str[k++] = hexDigits[byte0 & 0xf];
}
return new String(str);
}catch(Exception e){
return null;
}
}
%>
<%
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
String action = request.getParameter("action");
if("login".equals(action)){
String account = request.getParameter("account");
String password = request.getParameter("password");
int timeout = new Integer(request.getParameter("timeout"));
String ssid = calcMD5(account + KEY);
Cookie accountCookie = new Cookie("account", account);
accountCookie.setMaxAge(timeout);
Cookie ssidcCookie = new Cookie("ssid", ssid);
ssidcCookie.setMaxAge(timeout);
response.addCookie(accountCookie);
response.addCookie(ssidcCookie);
response.sendRedirect(request.getRequestURI() + "?" + System.currentTimeMillis());
return;
}
else if ("logout".equals(action)){
Cookie accountCookie = new Cookie("account", "");
accountCookie.setMaxAge(0);
Cookie ssidcCookie = new Cookie("ssid", "");
ssidcCookie.setMaxAge(0);
response.addCookie(accountCookie);
response.addCookie(ssidcCookie);
response.sendRedirect(request.getRequestURI() + "?" + System.currentTimeMillis());
return;
}
boolean login = false;
String account = null;
String ssid = null;
if (request.getCookies() != null){
for(Cookie cookie: request.getCookies()){
if(cookie.getName().equals("account"))
account = cookie.getValue();
if(cookie.getName().equals("ssid"))
ssid = cookie.getValue();
}
if(account != null && ssid != null){
login = ssid.equals(calcMD5(account + KEY));
}
%>
<legend><%=login ? "歡迎回來" : "請先登陸" %></legend>
<%if(login){ %>
歡迎你, ${cookie.account.value}.
<a href="${pageContext.request.requestURI}?action=logout">注銷</a>
<%} else { %>
<form action="${pageContext.request.requestURI}?action=login" method="post">
<table>
<tr><td>帳號:</td>
<td><input type="text" name="account" style="width=200px; "/></td>
<tr><td>密碼: