pls help, (Access is denied) error when file upload to a local directory

Hi, I've been stuck on this for the past few days and I am quite new at developing web application.

Here is the problem that I am having, I don't know why it keeps on saying "access is denied" when I can see that the file is uploaded to the directory. I am developing a JSP page file upload using Jakarta Fileupload v1.2. However, every time when I try to upload a file to a local path (e:\temp) on the server I keep getting this problem. I even try looking into the server.policy file on glassfish but no luck, your help is appreciated thanks

Here's the log after file upload, note: I can see the file being uploaded in the e:\temp but why does it keep telling me the error?

I'm using netbean 5.5.1 and glassfish v2

Initializing Sun's JavaServer Faces implementation (1.2_04-b10-p01) for context '/TestReport'

java.io.FileNotFoundException: e:\temp (Access is denied)

at java.io.FileOutputStream.open(Native Method)

at java.io.FileOutputStream.<init>(FileOutputStream.java:179)

at java.io.FileOutputStream.<init>(FileOutputStream.java:131)

at org.apache.commons.fileupload.disk.DiskFileItem.write(DiskFileItem.java:390)

at org.apache.jsp.ProcessFileUpload_jsp._jspService(ProcessFileUpload_jsp.java:83)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:80)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:818)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:464)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:358)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:818)

at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:398)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)

at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:258)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:189)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:564)

at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:81)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:193)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:564)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:558)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1067)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:564)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:558)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1067)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:255)

at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:618)

at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:549)

at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:790)

at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:326)

at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:248)

at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:199)

at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:345)

at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)

at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:93)

[4269 byte] By [arckjmastera] at [2007-11-27 1:34:09]
# 1

> Hi, I've been stuck on this for the past few days and

> I am quite new at developing web application.

>

> Here is the problem that I am having, I don't know

> why it keeps on saying "access is denied" when I can

> see that the file is uploaded to the directory. I am

> developing a JSP page file upload using Jakarta

> Fileupload v1.2. However, every time when I try to

> upload a file to a local path (e:\temp)

Hi there,

Typically in a Web Container, applications are deployed to a folder called webapps (this is the case in Tomcat, I'm not sure about Glassfish)

So the directory structure is something like C:/Tomcat/webapps/MyApplication/other folders......

When you upload a file , you normally can upload it only to a folder under your application and not to a folder outside the application.

First you can try to upload the file to a folder under the webapp and not outside the webapp, once you get that to work then internally in the Servlet you can write code to save the file to any directory on the server, but the Servlet must be located on the server.

appy77a at 2007-7-12 0:41:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Can a standard java program write to that disk?

Just write a quick test app that tries to create a file there.

I don't think you are limited to writing into any specific area, though this sort of code is better handled in a servlet rather than a JSP.

The only limitations would be user rights standard with windows.

Does that directory have any security permissions on it?

What user is Tomcat running as?

Is Tomcat running as a service, or an app?

Does that user have permission to write to that directory?

evnafetsa at 2007-7-12 0:41:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...