cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kogan Irina <Irina.Ko...@mchp.siemens.de>
Subject RE: File upload in cocoon: org.apache.cocoon.components.request.m ultipart.FilePart is missing.
Date Fri, 16 May 2003 15:58:34 GMT
Thank you very much for your answer!

I have written the file UploadTest.jar (for now doing pretty much nothing)
and put the class UploadTest into the package upload.test:

package upload.test;

import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.cocoon.acting.Action;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.servlet.multipart.*;

import java.util.Map;
import java.io.File;

public class UploadTest 
  extends AbstractLogEnabled 
  implements Action, ThreadSafe
{
    public Map act(Redirector redirector, SourceResolver resolver,
                   Map objectModel, String source, Parameters par)
        throws Exception
    {
        Request request = ObjectModelHelper.getRequest(objectModel);
        // FilePart filePart = (FilePart) request.get("uploaded_file");
        Part part = (Part) request.get("blah");

        // File file = ((PartFile)filePart).getFile();

        // getLogger().debug("Uploaded file = " + file.getCanonicalPath());
        // here you can open an InputStream on the file or whatever
        // you may also want to delete the file after using it
        return null;
    }
}

Then I compile this file (no errors encountered) and create UploadTest.jar
from UploadTest.class.  Then I put this file into lib directory of cocoon in
TomCat where all jar files are.

Then to the main sitemap (for all samples) I add this action
<map:action name="upload" src="upload.test.UploadTest"/>

And I have the following in the sitemap in my test sample:

<map:match pattern="*.html">
    <map:read src="{1}.html"/>
</map:match>
		    
<map:match pattern="file">
     <map:act type="upload" src="optional src"> 
     	   <map:generate type="html" src="success.html"/>
     </map:act>
     <map:serialize/>
</map:match>

When I go to the page http://localhost:8080/cocoon/samples/test/upload.html,
I get the following error message:

Internal Server Error


Message: null

Description: No details available.

Sender: org.apache.cocoon.servlet.CocoonServlet

Source: Cocoon Servlet

Request URI

   samples/test/upload.html

cause

   upload.test.UploadTest

request-uri

   /cocoon/samples/test/upload.html


Do you know what is wrong?  Thanks a million!

Have a good weekend!

Irina.

> -----Original Message-----
> From: Geoff Howard [mailto:cocoon@leverageweb.com]
> Sent: Freitag, 16. Mai 2003 04:41
> To: cocoon-users@xml.apache.org
> Subject: RE: File upload in cocoon:
> org.apache.cocoon.components.request.multipart.FilePart is missing.
> 
> 
> Yes, this was moved and slightly refactored and even the wiki hasn't
> totally caught up yet.  Even though you want to do this in an action,
> you should find what you need here:
> http://wiki.cocoondev.org/Wiki.jsp?page=FileUploadsWithFlow
> 
> Notice the new package is org.apache.cocoon.servlet.multipart - some
> of the class names have changed, but most of the concepts are the
> same.  The bottom section should give you what you need to fix the
> action for uploads - if not, write back.
> 
> By the way, the jars.html you refer to is for 2.0.x (as is 
> all of the live
> site for now).  The maybeupload jar is no longer an option (nor was it
> useful in the recent past).
> 
> HTH,
> Geoff Howard
> 
> > -----Original Message-----
> > From: Kogan Irina [mailto:Irina.Kogan@mchp.siemens.de]
> > Sent: Thursday, May 15, 2003 10:58 AM
> > To: cocoon-users@xml.apache.org
> > Subject: File upload in cocoon:
> > org.apache.cocoon.components.request.multipart.FilePart is missing.
> >
> >
> > Hello all,
> >
> > I am trying to upload a file using Cocoon, as
> > 
http://wiki.cocoondev.org/Wiki.jsp?page=FileUploadWithAction suggests.
> However, for some reason
> org.apache.cocoon.components.request.multipart.FilePart (to be imported to
> my UploadTest) is not in any of the jars files in the
> \jakarta-tomcat-4.1.24-LE-jdk14\webapps\cocoon\WEB-INF\lib directory.  (I
> would assume it should be in cocoon-2.1-M1.jar, since
> org.apache.cocoon.components is there, but it is not there.)  Does anybody
> know where I can get this package?
>
> In the http://xml.apache.org/cocoon/installing/jars.html, they are talking
> about the optional jar file for servlet upload support.  Do I
> need that or a
> special build target (a parameter for "built.bat" for ant) to get upload
> support?
>
> Does anybody know how to insert upload into the 2.1 build process or with
> what class the old one has been replaced?
>
> Thanks a lot in advance,
>
> Irina.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Mime
View raw message