aspose file tools*
The moose likes Servlets and the fly likes Has anybody FileUpload.class containing setSizeMax() method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic

Has anybody FileUpload.class containing setSizeMax() method?

yoman sharma

Joined: Feb 10, 2005
Posts: 13
Hi actually my servlet code uses FileUpload.setSizeMax() method. But the class file which i have don't posses this method so i am getting the following message everytime

java.lang.NoSuchMethodError: org.apache.commons.fileupload.FileUpload.setSizeMax(I)V
com.jspbook.FileUploadCommons.doPost(Unknown Source)

THe servlet code which causes this exception is as follows in which setSizeMax() is called with the help of FileUpload reference.

package com.jspbook;

import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.commons.fileupload.*;
import java.util.*;

public class FileUploadCommons extends HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {

PrintWriter out = response.getWriter();

out.print("File upload success. <a href=\"/jspbook/files/");
out.print("\">Click here to browse through all uploaded ");

ServletContext sc = getServletContext();
String path = sc.getRealPath("/files");
org.apache.commons.fileupload.FileUpload fu = new
try {
List l = fu.parseRequest(request);
Iterator i = l.iterator();
while (i.hasNext()) {
FileItem fi = (FileItem);
// trim out full path info if it is included
String filename = fi.getName();
int slash = filename.lastIndexOf("\\");
if (slash != -1) {
filename = filename.substring(slash + 1);
// write the file to the 'files' directory
catch (Exception e) {
throw new ServletException(e);

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
doPost(request, response);

So please can anybody send me the class file of FileUpload which contains this setSizeMax() method or suggest me a method to resolve this.

THanks in Advance
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Do you have struts.jar in your app somewhere?

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
yoman sharma

Joined: Feb 10, 2005
Posts: 13
No i don't have struts.jar
What to do?
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

This conversation is happening twice in this forum.
I'm closing this copy, the other is here.

I agree. Here's the link:
subject: Has anybody FileUpload.class containing setSizeMax() method?
Similar Threads
Query about usage of API :detailed description
Where to place the jar files
Please tell the reason for errors in the code. CODE and Errors given
problem in using Servlet API for file upload
Detailed description for william : regarding JAR files