aspose file tools*
The moose likes Servlets and the fly likes MultipartRequest syntax question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "MultipartRequest syntax question" Watch "MultipartRequest syntax question" New topic
Author

MultipartRequest syntax question

Garann Means
Ranch Hand

Joined: Jan 28, 2002
Posts: 214
Hi,
I'm trying to use MultipartRequest to upload a file. When I get to the servlet, I get:

java.lang.IllegalArgumentException: Not a directory: /images
at com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:211)
at com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:106)
at com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:86)
at testPad.Uploader.doPost(Uploader.java:19)........

The MultipartRequest object in the servlet is instantiated thusly:
MultipartRequest mpRequest = new MultipartRequest(request,"/images");

I also tried it without the slash, but the results were the same.
Finally, this is my directory structure:

Can anyone help me correct this? Thanks!
g.
[ August 08, 2002: Message edited by: Garann Rose Means ]
Sandeep Jain
Ranch Hand

Joined: Oct 25, 2000
Posts: 124
Well , what I feel here there is no way u can achieve this fuctionality without modifying the MultipartRequest.java file .
So what u can do is inside the constructor of MultipartRequest file u can check for the file type or ur condition on which u want to put ur file in the respective directory and make the call to its other constructor which takes 2 parameters and can set the direcory also .


Try and Try Till u succeed<br /> <br />Sandeep Jain
Sandeep Jain
Ranch Hand

Joined: Oct 25, 2000
Posts: 124
Sorry , I just enter the comments in the wrong window, they were answer to some other question so please do not bother .
What u can try out here is give the absolute path of the directory .
Garann Means
Ranch Hand

Joined: Jan 28, 2002
Posts: 214
I ended up just sending an email to the contact address listed on the servlets.com website.
Jason Hunter responded:
It can be either (relative or absolute -g.). If relative it's relative to the current directory of
the web server process. Save a "foo.txt" and you'll see where that is,
or you'll get an error msg since it's very likely unwritable on Unix.

..In case anyone else was wondering the same thing.
g.
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399


MultipartRequest mpRequest = new MultipartRequest(request,"/images");


dear
what i can think is MultipartRequest doesnt hv a constructor with 2 arguments viz. (Request,PATH), make such a contstructor in Java file & then try using it...
HTH
malhar
Garann Means
Ranch Hand

Joined: Jan 28, 2002
Posts: 214
Malhar,
Check the JavaDoc. The first constructor is
MultipartRequest(javax.servlet.http.HttpServletRequest request, java.lang.String saveDirectory)
Constructs a new MultipartRequest to handle the specified request, saving any uploaded files to the given directory, and limiting the upload size to 1 Megabyte.

Thanks anyway.
g.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MultipartRequest syntax question