FileUpload: parseRequest (request) returning null

I developed this application using Struts and I can upload a file using Struts2. I am trying to upload a file using Servlet in the same web application. But parseRequest (request) returns null.

Servlet Code:

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { isMultipart = ServletFileUpload.isMultipartContent(request); response.setContentType("text/html"); FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); try { List fileItems = upload.parseRequest(request); Iterator i = fileItems.iterator(); while (i.hasNext()) { ........ } 

I looked through many Stackoverflow articles and questions, but none of them helped solve the problem.
I read the stackoverflow question in the comments, struts2 may cause this problem. If this is true? How can I handle this.

Thanks in advance for your help.

-1
source share

All Articles