Dear friends,
i am working on winnt/ie5 and trying to upload certain
files from the client machine using the
multipart/form-data ( rfc 1867)

When i try to run the jsp page containing the
appropriate parsing machenism, i get the following
error message, i am unable to understand the thing.
Please if anybody can help me.

=======================================================
Error: 500
Internal Servlet Error:

javax.servlet.ServletException: access denied
(java.io.FilePermission d:\upload-tests read)
        at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:384)
        at
_0005cupload_0002ejspupload_jsp_2._jspService(_0005cupload_0002ejspupload_jsp_2.java:110)
        at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
        at
javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
        at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:161)
        at
org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:247)
        at
org.apache.jasper.runtime.JspServlet.service(JspServlet.java:352)
        at
javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
        at
org.apache.tomcat.core.ServiceInvocationHandler.method(ServletWrapper.java:626)
        at
org.apache.tomcat.core.ServletWrapper.handleInvocation(ServletWrapper.java:534)
        at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:378)
        at
org.apache.tomcat.core.Context.handleRequest(Context.java:644)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:440)
        at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:144)
        at
org.apache.tomcat.service.TcpConnectionThread.run(TcpEndpoint.java:310)
        at java.lang.Thread.run(Thread.java:479)

Root cause:
java.security.AccessControlException: access denied
(java.io.FilePermission d:\upload-tests read)
        at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:195)
        at
java.security.AccessController.checkPermission(AccessController.java:403)
        at
java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
        at
java.lang.SecurityManager.checkRead(SecurityManager.java:873)
        at java.io.File.isDirectory(File.java:566)
        at
com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:114)
        at
_0005cupload_0002ejspupload_jsp_2._jspService(_0005cupload_0002ejspupload_jsp_2.java:75)
        at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
        at
javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
        at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:161)
        at
org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:247)
        at
org.apache.jasper.runtime.JspServlet.service(JspServlet.java:352)
        at
javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
        at
org.apache.tomcat.core.ServiceInvocationHandler.method(ServletWrapper.java:626)
        at
org.apache.tomcat.core.ServletWrapper.handleInvocation(ServletWrapper.java:534)
        at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:378)
        at
org.apache.tomcat.core.Context.handleRequest(Context.java:644)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:440)
        at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:144)
        at
org.apache.tomcat.service.TcpConnectionThread.run(TcpEndpoint.java:310)
        at java.lang.Thread.run(Thread.java:479)

=======================================================The
jsp page for parsing
--------------------------

<%@ page language="java"%>
<%@ page import="com.oreilly.servlet.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%
        String dirStr = new String("d:/upload-tests");

        File dir = new File(dirStr);
        MultipartRequest mpr = new MultipartRequest(request,
dirStr, 3000000);

        Enumeration files = mpr.getFileNames();
        String fileName=null;
        File f=null;
        int counter=0;

        while(files.hasMoreElements())
        {
                fileName = new String((String)files.nextElement());
                f = mpr.getFile(fileName);
                if(dir.canRead() && dir.canWrite())
                {
                        if(f.renameTo(new File(fileName+(new
Date().getTime()))))
                        {
                                out.println("Successfully written file " +
++counter);
                        }
                        else
                        {
                                System.out.println("Error in writing file " +
fileName);
                                out.println("couldn't create file " );
                        }
                }
                else
                        out.println("No write permission in the directory
");
        }

%>
This page shall upload the file onto ther server
=======================================================

The multipartrequest class used here is taken with
gratitude from Servlets.com (jason hunter )


waiting for a quick reply,

regards

raghav


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to