gpt4 book ai didi

eclipse - 运行我的 servlet 页面时 HTTP 错误 404 意味着使用 JSP 和 servlet 从数据库下载长 BLOB 文件

转载 作者:行者123 更新时间:2023-11-29 00:01:36 25 4
gpt4 key购买 nike

这是我的 JSP 页面,它显示一个表并重定向到 servlet 的 url。单击“保存”按钮时收到的错误是“HTTP 状态 404 - 未找到”。附言。我还制作了另一个 jsp,它是使用 doPost 上传文件的 servlet,它工作得很好,但只有项目的这一部分已经困扰我将近一个星期了!

<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Admin's page</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="<%=request.getContextPath() %>/bootstrap/css/bootstrap.min.css">
<script src="bootstrap/js/jquery.min.js"></script>
<script src="bootstrap/js/popper.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
</head>
<body>

<!-- <div class="container-fluid">
<h1>Admin's page</h1>
<p>Table with downloadable files uploaded by each manager</p>
<div class="row">
<div class="col-sm-4" style="background-color:lavender;">User IDs</div>
<div class="col-sm-8" style="background-color:lavenderblush;">Uploaded File</div>
</div>
</div>

</body>
</html> -->

<div class="container-fluid">
<h2 style="text-align: center">Admin's page</h2>
<p style="text-align: center">Table with downloadable files uploaded by each manager</p>
<table class="table">
<thead class="thead-light">
<tr>
<th>ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>File</th>
</tr>
</thead>
<tbody>
<%
try
{
Class.forName("com.mysql.cj.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/login";
String username="root";
String password="your-password";
String query="select * from employeesloginaccount";
Connection conn=DriverManager.getConnection(url, username, password);
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(query);
while(rs.next())
{

%>
<tr>
<td><%=rs.getInt("id") %></td>
<td><%=rs.getString("first_name") %></td>
<td><%=rs.getString("last_name") %></td>
<td>
<form method="get" action="<%=request.getContextPath()%>/downloadFileServlet/?id="<%=rs.getInt("id") %> >
<input style="text-align: center" type="submit" value="Save">
</form>
</td>
</tr>
<%

}
%>
</tbody>
</table>
<%
rs.close();
stmt.close();
conn.close();
}
catch(Exception e)
{
e.printStackTrace();
}
%>
</div>
</body>
</html>

我的 servlet 页面,

package servlets;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



@WebServlet("/downloadFileServlet")
@MultipartConfig(maxFileSize = 536870912)
public class DBFileDownloadServlet extends HttpServlet {



private static final long serialVersionUID = 1L;

// size of byte buffer to send file
private static final int BUFFER_SIZE = 536870912;

// database connection settings
private String dbURL = "jdbc:mysql://localhost:3306/login";
private String dbUser = "root";
private String dbPass = "your-password";

protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// get upload id from URL's parameters
int uploadId = Integer.parseInt(request.getParameter("id"));

Connection conn = null;
String message="";// connection to the database

try {
// connects to the database
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
conn = DriverManager.getConnection(dbURL, dbUser, dbPass);

// queries the database
String sql = "SELECT file FROM employeesloginaccount WHERE upload_id = ?";
PreparedStatement statement = conn.prepareStatement(sql);
statement.setInt(1, uploadId);

ResultSet result = statement.executeQuery();
if (result.next()) {
// gets file name and file blob data
String fileName = result.getString("file_name");
Blob blob = result.getBlob("file_data");
InputStream inputStream = blob.getBinaryStream();
int fileLength = inputStream.available();

System.out.println("fileLength = " + fileLength);

ServletContext context = getServletContext();

// sets MIME type for the file download
String mimeType = context.getMimeType(fileName);
if (mimeType == null) {
mimeType = "application/octet-stream";

}

// set content properties and header attributes for the response
response.setContentType(mimeType);
response.setContentLength(fileLength);
String headerKey = "Content-Disposition";
String headerValue = String.format("attachment; filename=\"%s\"", fileName);
response.setHeader(headerKey, headerValue);

// writes the file to the client
OutputStream outStream = response.getOutputStream();

byte[] buffer = new byte[BUFFER_SIZE];
int bytesRead = -1;

while ((bytesRead = inputStream.read(buffer)) != -1) {
outStream.write(buffer, 0, bytesRead);
}

inputStream.close();
outStream.close();
message="File successfully downloaded";
} else {
// no file found
message="No file to be downloaded";
response.getWriter().print("File not found for the id: " + uploadId);
}
} catch (SQLException ex) {
ex.printStackTrace();
response.getWriter().print("SQL Error: " + ex.getMessage());
} catch (IOException ex) {
ex.printStackTrace();
response.getWriter().print("IO Error: " + ex.getMessage());
} finally {
if (conn != null) {
// closes the database connection
try {
conn.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
// sets the message in request scope
request.setAttribute("Message", message);

// forwards to the message page
getServletContext().getRequestDispatcher("/JSPs/Message.jsp").forward(request, response);

}
}
}

控制台显示以下内容,但我仍然必须通过它找出任何错误。

May 17, 2018 4:03:31 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:MajorProject' did not find a matching property.
May 17, 2018 4:03:31 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:registration' did not find a matching property.
May 17, 2018 4:03:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/8.5.30
May 17, 2018 4:03:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Apr 3 2018 20:04:09 UTC
May 17, 2018 4:03:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 8.5.30.0
May 17, 2018 4:03:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 8.1
May 17, 2018 4:03:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 6.3
May 17, 2018 4:03:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
May 17, 2018 4:03:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: C:\Program Files\Java\jre1.8.0_162
May 17, 2018 4:03:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_162-b12
May 17, 2018 4:03:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
May 17, 2018 4:03:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: E:\eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
May 17, 2018 4:03:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: E:\Stationery\apache-tomcat-8.5.30
May 17, 2018 4:03:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=E:\eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
May 17, 2018 4:03:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=E:\Stationery\apache-tomcat-8.5.30
May 17, 2018 4:03:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=E:\eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps
May 17, 2018 4:03:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=E:\Stationery\apache-tomcat-8.5.30\endorsed
May 17, 2018 4:03:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
May 17, 2018 4:03:31 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jre1.8.0_162\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_162/bin/server;C:/Program Files/Java/jre1.8.0_162/bin;C:/Program Files/Java/jre1.8.0_162/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin;C:\Program Files\Java\jdk1.8.0_162\bin;E:\eclipse1;;.]
May 17, 2018 4:03:32 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
May 17, 2018 4:03:32 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
May 17, 2018 4:03:32 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
May 17, 2018 4:03:32 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
May 17, 2018 4:03:32 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 932 ms
May 17, 2018 4:03:32 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Catalina]
May 17, 2018 4:03:32 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.5.30
May 17, 2018 4:03:32 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
May 17, 2018 4:03:33 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
May 17, 2018 4:03:33 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
May 17, 2018 4:03:33 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
May 17, 2018 4:03:33 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 981 ms

下面给出了新错误 HTTP Status 500 Internal Server Error 的堆栈跟踪,但首先我提到了运行代码时在 chrome 中给出的堆栈跟踪部分

java.lang.NumberFormatException: null
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
servlets.DBFileDownloadServlet.doGet(DBFileDownloadServlet.java:41)
javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

May 17, 2018 10:50:57 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:MajorProject' did not find a matching property.
May 17, 2018 10:50:57 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:registration' did not find a matching property.
May 17, 2018 10:50:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/8.5.30
May 17, 2018 10:50:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Apr 3 2018 20:04:09 UTC
May 17, 2018 10:50:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 8.5.30.0
May 17, 2018 10:50:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 8.1
May 17, 2018 10:50:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 6.3
May 17, 2018 10:50:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
May 17, 2018 10:50:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: C:\Program Files\Java\jre1.8.0_162
May 17, 2018 10:50:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_162-b12
May 17, 2018 10:50:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
May 17, 2018 10:50:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: E:\eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
May 17, 2018 10:50:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: E:\Stationery\apache-tomcat-8.5.30
May 17, 2018 10:50:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=E:\eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
May 17, 2018 10:50:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=E:\Stationery\apache-tomcat-8.5.30
May 17, 2018 10:50:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=E:\eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps
May 17, 2018 10:50:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=E:\Stationery\apache-tomcat-8.5.30\endorsed
May 17, 2018 10:50:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
May 17, 2018 10:50:57 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jre1.8.0_162\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_162/bin/server;C:/Program Files/Java/jre1.8.0_162/bin;C:/Program Files/Java/jre1.8.0_162/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin;C:\Program Files\Java\jdk1.8.0_162\bin;E:\eclipse1;;.]
May 17, 2018 10:50:57 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
May 17, 2018 10:50:58 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
May 17, 2018 10:50:58 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
May 17, 2018 10:50:58 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
May 17, 2018 10:50:58 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2107 ms
May 17, 2018 10:50:58 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Catalina]
May 17, 2018 10:50:58 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.5.30
May 17, 2018 10:50:59 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
May 17, 2018 10:50:59 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
May 17, 2018 10:50:59 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
May 17, 2018 10:50:59 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
May 17, 2018 10:50:59 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1584 ms
1
May 17, 2018 10:53:08 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [servlets.DBFileDownloadServlet] in context with path [/MajorProject] threw exception
java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at servlets.DBFileDownloadServlet.doGet(DBFileDownloadServlet.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
java.sql.SQLSyntaxErrorException: Unknown column 'upload_id' in 'where clause'
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:118)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:960)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1019)
at servlets.DBFileDownloadServlet.doGet(DBFileDownloadServlet.java:56)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
May 17, 2018 10:55:45 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [servlets.DBFileDownloadServlet] in context with path [/MajorProject] threw exception
java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at servlets.DBFileDownloadServlet.doGet(DBFileDownloadServlet.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

最佳答案

JSP 中的表单获取 URL 不正确,删除 servlet 名称后和查询参数前的“/”。

关于eclipse - 运行我的 servlet 页面时 HTTP 错误 404 意味着使用 JSP 和 servlet 从数据库下载长 BLOB 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50389410/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com