aspose file tools*
The moose likes JSP and the fly likes Not A Directory - MultipartRequest problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Not A Directory - MultipartRequest problem" Watch "Not A Directory - MultipartRequest problem" New topic
Author

Not A Directory - MultipartRequest problem

Paid O'Cuana
Greenhorn

Joined: Mar 05, 2003
Posts: 24
I'm getting a java.lang.IllegalArgumentException when using the com.oreilly.servlet.MultipartParsrer class.
Here's the error:

Error: 500
Location: /accessability/newsupload.jsp
Internal Servlet Error:
javax.servlet.ServletException: Not a directory: http://www.lucidity.dev/accessability/images/
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
at accessability.newsupload_3._jspService(newsupload_3.java:120)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Ajp13Interceptor.processConnection(Ajp13Interceptor.java:341)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:534)
Root cause:
java.lang.IllegalArgumentException: Not a directory: http://www.lucidity.dev/accessability/images/
at com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:214)
at upload.uploadBean.doUpload(uploadBean.java:95)
at accessability.newsupload_3._jspService(newsupload_3.java:86)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Ajp13Interceptor.processConnection(Ajp13Interceptor.java:341)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:534)

Now, the directory specified is most definitely a directory. I've changed it many times to see will it accept any directory value, but it won't. The bean I use is uploadBean.java, in the package upload. Initially, I had my com.oreilly classes in this upload package, but that caused different problems, so I put the "com" folder in my WEB-INF/classes. That's when this error began.
In my JSP:
Vector vctInfo = new Vector();
vctInfo = uploadBean.doUpload(request);
In my bean's "doUpload" method:
MultipartRequest multi =new MultipartRequest(request, "http://www.lucidity.dev/accessability/images/", 10*200*200,
"ISO-8859-1", new DefaultFileRenamePolicy());

Has anyone had this problem or anything similar?
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
In my bean's "doUpload" method:
MultipartRequest multi = new MultipartRequest(request, "http://www.lucidity.dev/accessability/images/", 10*200*200,
"ISO-8859-1", new DefaultFileRenamePolicy());

Why are you using the full path http://www.lucidity.dev/accessability/images/
place your images directory in /defaultroot folder and use getServletContext().getRealPath("/images") method to get the real path of the images directory
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61606
    
  67

You are using a URL to specify the directory. This must be the actual path to the file in the file system, not a URL.
If the file is to be stored within the boundaries of the web app (not a great idea in my opinion), the getRealPath() method can be used to determine the path as Ali pointed out.
The most common schenario is for the path for uploaded files to be provided as an init parameter in either a properties file or directly in the web.xml as a context parameter as appropriate.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paid O'Cuana
Greenhorn

Joined: Mar 05, 2003
Posts: 24
Thanks lads, that worked.
 
 
subject: Not A Directory - MultipartRequest problem