Java HTTP状态500错误:无法为JSP编译类
我试图在JSP页面上显示MySQL表。为此,我使用了JSP文件中的所有Java代码,但有一个错误,我无法修复它。 这里还添加了连接文件和util文件中的所有功能。 eclipse中也有一个错误,说有语法错误,但我无法检测到它们。 这些错误是由Java HTTP状态500错误:无法为JSP编译类,java,mysql,sql-server,jsp,Java,Mysql,Sql Server,Jsp,我试图在JSP页面上显示MySQL表。为此,我使用了JSP文件中的所有Java代码,但有一个错误,我无法修复它。 这里还添加了连接文件和util文件中的所有功能。 eclipse中也有一个错误,说有语法错误,但我无法检测到它们。 这些错误是由try/catch和while循环生成的 下面是使用Java的JSP <%@page import="java.sql.DriverManager"%> <%@page import="java.sql.Res
try/catch
和while
循环生成的
下面是使用Java的JSP
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%
String id = request.getParameter("username");
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/kiaora";
String database = "kiaora";
String username = "root";
String password = "1234Ishini";
try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>All Bills</title>
<link rel = "stylesheet" href = "Styles/bill_styles.css"/>
</head>
<body>
<div class = "wrapper">
<div class = "header">
<center>
<img alt="logo" src="images/kiaora_logo.png" width="30%" height="30%" >
</center>
</div>
<div class = "navigation">
<ul class="breadcrumb">
<li><a href="#">Home</a></li>
<li><a href="#">Employee Portal</a></li>
<li><a href="adminAccount.jsp">Admin Account</a></li>
<li><a href="BillHome.jsp">Showroom</a></li>
<li>View All Bills</li>
</ul>
</div>
<center>
<h2>Bills</h2><br>
</center>
<!-- table -->
<table border="1">
<tr>
<th>Bill Code</th>
<th>Utility Type</th>
<th>Due Date</th>
<th>Status</th>
<th>Amount</th>
<th>Date</th>
<th>Month</th>
</tr>
<%
try {
connection = DriverManager.getConnection(url + database, username, password);
statement = connection.createStatement();
String sql = "select * from showroom_bill";
resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
%>
<tr>
<td><%=resultSet.getInt("bill_code")%></td>
<td><%=resultSet.getString("utility_type")%></td>
<td><%=resultSet.getString("dueDate")%></td>
<td><%=resultSet.getString("status")%></td>
<td><%=resultSet.getDouble("amount")%></td>
<td><%=resultSet.getInt("date")%></td>
<td><%=resultSet.getString("month")%></td>
</tr>
<%
}
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
%>
</table>
<div class = "footer clearfix">
<p>Copyright©2021 KIAORA Enterprises</p>
<ul>
<li><a href = "#">Facebook</a></li>
<li><a href = "#">Twitter</a></li>
<li><a href = "#">Instagram</a></li>
<li><a href = "#">RSS feed</a></li>
</ul>
</div> <!-- footer -->
</div><!-- wrapper -->
</body>
</html>
所有账单
- 查看所有帐单
账单
票据代码
实用类型
到期日
地位
数量
日期
月
版权所有©2021 KIAORA Enterprises
错误
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: [12] in the jsp file: [/BillViewAll.jsp]
Syntax error on token "âââââââ", { expected
9: String database = "kiaora";
10: String username = "root";
11: String password = "1234Ishini";
12: try {​​​​​​​
13: Class.forName(driver);
14: }​​​​​​​ catch (ClassNotFoundException e) {​​​​​​​
15: e.printStackTrace();
An error occurred at line: [14] in the jsp file: [/BillViewAll.jsp]
Syntax error, insert "VariableDeclarators" to complete LocalVariableDeclaration
11: String password = "1234Ishini";
12: try {​​​​​​​
13: Class.forName(driver);
14: }​​​​​​​ catch (ClassNotFoundException e) {​​​​​​​
15: e.printStackTrace();
16: }​​​​​​​
17: Connection connection = null;
An error occurred at line: [14] in the jsp file: [/BillViewAll.jsp]
Syntax error, insert ";" to complete LocalVariableDeclarationStatement
11: String password = "1234Ishini";
12: try {​​​​​​​
13: Class.forName(driver);
14: }​​​​​​​ catch (ClassNotFoundException e) {​​​​​​​
15: e.printStackTrace();
16: }​​​​​​​
17: Connection connection = null;
An error occurred at line: [14] in the jsp file: [/BillViewAll.jsp]
Syntax error, insert "}" to complete Block
11: String password = "1234Ishini";
12: try {​​​​​​​
13: Class.forName(driver);
14: }​​​​​​​ catch (ClassNotFoundException e) {​​​​​​​
15: e.printStackTrace();
16: }​​​​​​​
17: Connection connection = null;
An error occurred at line: [14] in the jsp file: [/BillViewAll.jsp]
âââââââ cannot be resolved
11: String password = "1234Ishini";
12: try {​​​​​​​
13: Class.forName(driver);
14: }​​​​​​​ catch (ClassNotFoundException e) {​​​​​​​
15: e.printStackTrace();
16: }​​​​​​​
17: Connection connection = null;
An error occurred at line: [14] in the jsp file: [/BillViewAll.jsp]
âââââââ cannot be resolved to a type
11: String password = "1234Ishini";
12: try {​​​​​​​
13: Class.forName(driver);
14: }​​​​​​​ catch (ClassNotFoundException e) {​​​​​​​
15: e.printStackTrace();
16: }​​​​​​​
17: Connection connection = null;
An error occurred at line: [15] in the jsp file: [/BillViewAll.jsp]
Duplicate local variable e
12: try {​​​​​​​
13: Class.forName(driver);
14: }​​​​​​​ catch (ClassNotFoundException e) {​​​​​​​
15: e.printStackTrace();
16: }​​​​​​​
17: Connection connection = null;
18: Statement statement = null;
An error occurred at line: [15] in the jsp file: [/BillViewAll.jsp]
Syntax error on token ".", ; expected
12: try {​​​​​​​
13: Class.forName(driver);
14: }​​​​​​​ catch (ClassNotFoundException e) {​​​​​​​
15: e.printStackTrace();
16: }​​​​​​​
17: Connection connection = null;
18: Statement statement = null;
An error occurred at line: [15] in the jsp file: [/BillViewAll.jsp]
The method printStackTrace() is undefined for the type BillViewAll_jsp
12: try {​​​​​​​
13: Class.forName(driver);
14: }​​​​​​​ catch (ClassNotFoundException e) {​​​​​​​
15: e.printStackTrace();
16: }​​​​​​​
17: Connection connection = null;
18: Statement statement = null;
An error occurred at line: [16] in the jsp file: [/BillViewAll.jsp]
âââââââ cannot be resolved to a type
13: Class.forName(driver);
14: }​​​​​​​ catch (ClassNotFoundException e) {​​​​​​​
15: e.printStackTrace();
16: }​​​​​​​
17: Connection connection = null;
18: Statement statement = null;
19: ResultSet resultSet = null;
An error occurred at line: [17] in the jsp file: [/BillViewAll.jsp]
Syntax error, insert ";" to complete LocalVariableDeclarationStatement
14: }​​​​​​​ catch (ClassNotFoundException e) {​​​​​​​
15: e.printStackTrace();
16: }​​​​​​​
17: Connection connection = null;
18: Statement statement = null;
19: ResultSet resultSet = null;
20: %>
An error occurred at line: [17] in the jsp file: [/BillViewAll.jsp]
connection cannot be resolved to a variable
14: }​​​​​​​ catch (ClassNotFoundException e) {​​​​​​​
15: e.printStackTrace();
16: }​​​​​​​
17: Connection connection = null;
18: Statement statement = null;
19: ResultSet resultSet = null;
20: %>
An error occurred at line: [65] in the jsp file: [/BillViewAll.jsp]
âââââââ cannot be resolved to a type
62: <th>Month</th>
63: </tr>
64: <%
65: try {​​​​​​​
66: connection = DriverManager.getConnection(url + database, username, password);
67: statement = connection.createStatement();
68: String sql = "select * from showroom_bill";
An error occurred at line: [70] in the jsp file: [/BillViewAll.jsp]
âââââââ cannot be resolved to a type
67: statement = connection.createStatement();
68: String sql = "select * from showroom_bill";
69: resultSet = statement.executeQuery(sql);
70: while (resultSet.next()) {​​​​​​​
71: %>
72: <tr>
73: <td><%=resultSet.getInt("bill_code")%></td>
An error occurred at line: [71] in the jsp file: [/BillViewAll.jsp]
Duplicate local variable out
68: String sql = "select * from showroom_bill";
69: resultSet = statement.executeQuery(sql);
70: while (resultSet.next()) {​​​​​​​
71: %>
72: <tr>
73: <td><%=resultSet.getInt("bill_code")%></td>
74: <td><%=resultSet.getString("utility_type")%></td>
An error occurred at line: [71] in the jsp file: [/BillViewAll.jsp]
Syntax error on token ".", ; expected
68: String sql = "select * from showroom_bill";
69: resultSet = statement.executeQuery(sql);
70: while (resultSet.next()) {​​​​​​​
71: %>
72: <tr>
73: <td><%=resultSet.getInt("bill_code")%></td>
74: <td><%=resultSet.getString("utility_type")%></td>
An error occurred at line: [71] in the jsp file: [/BillViewAll.jsp]
The method write(String) is undefined for the type BillViewAll_jsp
68: String sql = "select * from showroom_bill";
69: resultSet = statement.executeQuery(sql);
70: while (resultSet.next()) {​​​​​​​
71: %>
72: <tr>
73: <td><%=resultSet.getInt("bill_code")%></td>
74: <td><%=resultSet.getString("utility_type")%></td>
An error occurred at line: [82] in the jsp file: [/BillViewAll.jsp]
Syntax error on token "âââââââ", { expected
79: <td><%=resultSet.getString("month")%></td>
80: </tr>
81: <%
82: }​​​​​​​
83: connection.close();
84: }​​​​​​​ catch (Exception e) {​​​​​​​
85: e.printStackTrace();
An error occurred at line: [84] in the jsp file: [/BillViewAll.jsp]
Syntax error, insert "VariableDeclarators" to complete LocalVariableDeclaration
81: <%
82: }​​​​​​​
83: connection.close();
84: }​​​​​​​ catch (Exception e) {​​​​​​​
85: e.printStackTrace();
86: }​​​​​​​
87: %>
An error occurred at line: [84] in the jsp file: [/BillViewAll.jsp]
Syntax error, insert ";" to complete LocalVariableDeclarationStatement
81: <%
82: }​​​​​​​
83: connection.close();
84: }​​​​​​​ catch (Exception e) {​​​​​​​
85: e.printStackTrace();
86: }​​​​​​​
87: %>
An error occurred at line: [84] in the jsp file: [/BillViewAll.jsp]
Syntax error, insert "}" to complete Block
81: <%
82: }​​​​​​​
83: connection.close();
84: }​​​​​​​ catch (Exception e) {​​​​​​​
85: e.printStackTrace();
86: }​​​​​​​
87: %>
An error occurred at line: [85] in the jsp file: [/BillViewAll.jsp]
Syntax error on token ".", ; expected
82: }​​​​​​​
83: connection.close();
84: }​​​​​​​ catch (Exception e) {​​​​​​​
85: e.printStackTrace();
86: }​​​​​​​
87: %>
88: </table>
An error occurred at line: [87] in the jsp file: [/BillViewAll.jsp]
Syntax error on token ".", ; expected
84: }​​​​​​​ catch (Exception e) {​​​​​​​
85: e.printStackTrace();
86: }​​​​​​​
87: %>
88: </table>
89:
90: <div class = "footer clearfix">
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:213)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:528)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:392)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:362)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:346)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:605)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:400)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Note The full stack trace of the root cause is available in the server logs.
org.apache.jasper.jaspereException:无法为JSP编译类:
jsp文件:[/BillViewAll.jsp]的第[12]行出现错误
标记“应为”{的语法错误
9:String database=“kiaora”;
10:String username=“root”;
11:String password=“1234Ishini”;
12:试试看
13:Class.forName(驱动程序);
第14条:捕获(ClassNotFoundException e){
15:e.printStackTrace();
jsp文件:[/BillViewAll.jsp]中的第[14]行出现错误
语法错误,请插入“VariableDeclarators”以完成LocalVariableDeclaration
11:String password=“1234Ishini”;
12:试试看
13:Class.forName(驱动程序);
第14条:捕获(ClassNotFoundException e){
15:e.printStackTrace();
16: }​​​​​​​
17:连接=null;
jsp文件:[/BillViewAll.jsp]中的第[14]行出现错误
语法错误,请插入“;”以完成LocalVariableDeclarationStatement
11:String password=“1234Ishini”;
12:试试看
13:Class.forName(驱动程序);
第14条:捕获(ClassNotFoundException e){
15:e.printStackTrace();
16: }​​​​​​​
17:连接=null;
jsp文件:[/BillViewAll.jsp]中的第[14]行出现错误
语法错误,插入“}”以完成块
11:String password=“1234Ishini”;
12:试试看
13:Class.forName(驱动程序);
第14条:捕获(ClassNotFoundException e){
15:e.printStackTrace();
16: }​​​​​​​
17:连接=null;
jsp文件:[/BillViewAll.jsp]中的第[14]行出现错误
无法解决问题
11:String password=“1234Ishini”;
12:试试看
13:Class.forName(驱动程序);
第14条:捕获(ClassNotFoundException e){
15:e.printStackTrace();
16: }​​​​​​​
17:连接=null;
jsp文件:[/BillViewAll.jsp]中的第[14]行出现错误
无法将–解析为类型
11:String password=“1234Ishini”;
12:试试看
13:Class.forName(驱动程序);
第14条:捕获(ClassNotFoundException e){
15:e.printStackTrace();
16: }​​​​​​​
17:连接=null;
jsp文件:[/BillViewAll.jsp]中的第[15]行出现错误
重复局部变量e
12:试试看
13:Class.forName(驱动程序);
第14条:捕获(ClassNotFoundException e){
15:e.printStackTrace();
16: }​​​​​​​
17:连接=null;
18:语句=null;
jsp文件:[/BillViewAll.jsp]中的第[15]行出现错误
令牌“.”上出现语法错误;应为
12:试试看
13:Class.forName(驱动程序);
第14条:捕获(ClassNotFoundException e){
15:e.printStackTrace();
16: }​​​​​​​
17:连接=null;
18:声明状态