I have Netbeans IDE 12.5, macOS BigSur 11.1, JDK 17, Apache Tomcat 10.0.16 and my project library contains servlet-api.jar, cos.jar, Java EE 7 API library jar files. I am making a servlet code for uploading of images through form. I am getting the error:
HTTP Status 500 – Internal Server Error
Type Exception Report
Message Unable to compile class for JSP:
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: [19] in the jsp file: [/process.jsp] The constructor MultipartRequest(HttpServletRequest, String) is undefined
This is my process.jsp file
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="com.oreilly.servlet.MultipartRequest" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String root=getServletContext().getRealPath("resources");
MultipartRequest m =new MultipartRequest(request,root);
out.print("File uploaded successfully");
%>
</body>
</html>
The addResource.jsp page code:
<%@page import= "java.util.Map" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>File Upload Demo</title>
</head>
<body>
<center>
<form method="post" action="process.jsp" enctype="multipart/form-data">
Select file to upload:
<input type="file" name="upload" />
<br/><br/>
<input type="submit" value="Upload" />
</form>
</center>
</body>
</html>