I am facing a problem while uploading a file through a java Servlet. I am using netBeans
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//(...)
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setSizeThreshold (maxMemSize);
factory.setRepository (new File ("/ home /"));
ServletFileUpload upload = new ServletFileUpload (factory);
upload.setSizeMax(maxFileSize);
List fileItems = upload.parseRequest (request); //here it gives the error
//data processing
}
Says:
incompatible types: HttpServletRequest cannot be converted to RequestContext.
Exception:
java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload.parseRequest
Even if I cast it into Requestcontext
, still it doesn't work
But if I do the parsing context to get the following error:
java.lang.ClassCastException: can not be cast to org.apache.catalina.core.ApplicationContextFacade org.apache.tomcat.util.http.fileupload.RequestContext
Thank you for your attention