我使用 TomCat,我收到一个错误“HTTP 状态 500 - 内部服务器错误,org.apache.jasper.JasperException:在第 [25] 行处理 [/login.jsp] 时发生异常。” 我不懂为什么。除了 arryalist 的 get (i) 方法外,一切都运行良好。这是代码:
<html>
<head>
<title>
Registrazione
</title>
</head>
<body>
<%@ page import="java.util.ArrayList" %>
<%! ArrayList<String> utenti = new ArrayList<String>(); %>
<%!String u; %>
<%
ServletContext us = getServletConfig().getServletContext();
ServletContext pw = getServletConfig().getServletContext();
ServletContext cont = getServletConfig().getServletContext();
//utenti.add(request.getParameter("usern"));
//in base al username e password inseriti controlla se presenti dentro l'arraylist ed in caso positivo fa login, altrimenti no
String use = request.getParameter("ulog");
String pass = request.getParameter("plog");
int conta=(int) cont.getAttribute("Conta");
u = (String) us.getAttribute("Username"+conta);
utenti.add(u);
for(int i=0;i<=conta;i++){
out.println(utenti.get(i));
}
out.println("USE " + use + "<br>");
out.println("ARRAY " + utenti + "<br>");
out.println("CONTA: " + conta);
//out.println(cont.getAttribute(" Conta") + " " + us.getAttribute("Username"+conta));
%>
<a href="index.html"> CLICCA </a>
</body>
</html>