cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Kromkamp" <>
Subject upload problem
Date Tue, 15 Jul 2003 07:23:09 GMT

I'm trying to upload an image with Cocoon. But when i'm trying to read the
parameters of the file in my Action it seems to be an String. What did I do

I've the following form:

<form action="addresidence.html" enctype="multipart/form-data">
            <input type="file" name="uploadfile" size="50"/>
            <input type="submit"/>

=================== (extends AbstractXMLFormAction implements FormListener)
import org.apache.cocoon.acting.AbstractXMLFormAction;
import org.apache.cocoon.components.xmlform.Form;
import org.apache.cocoon.components.xmlform.FormListener;
import org.apache.cocoon.servlet.multipart.Part;


HashMap parameters = new HashMap();

Enumeration parametersEnum = getRequest().getParameterNames();
System.out.println("Voor de while");
while( parametersEnum.hasMoreElements() ){
    String name = (String)parametersEnum.nextElement();
    Object value = getRequest().getParameter( name );

    System.out.println("Voor instanceof");
    System.out.println("instance of: "+value.getClass().getName());
    System.out.println("instance package: "+value.getClass().getPackage());
    System.out.println("instance to string: "+value.toString());
    if (value instanceof Part) {
    parameters.put( name, value );



    <map:match pattern="">
         <map:redirect-to uri="overview.html"/>

    <map:match pattern="wml/">
        <map:redirect-to uri="../overview.wml"/>

    <map:match pattern="overview.html">
        <map:read src="overview.html"/>

    <map:match pattern="overview.wml">
        <map:read src="overview.wml"/>

    <map:match pattern="img/*.gif">
        <map:read src="img/{1}.gif" mime-type="image/gif"  />

    <map:match pattern="img/*.jpg">
        <map:read src="img/{1}.jpg" mime-type="image/jpg"  />

    <map:match pattern="stylesheets/css/*.css">
        <map:read src="stylesheets/css/{1}.css" mime-type="text/css "  />

  <map:match pattern="addresidence.*">
	<map:act type="request">
      	<map:parameter name="parameters" value="true"/>
            <map:act type="MyAction">
			<map:generate src="upload.html"/>
			<map:serialize type="html" label="debug"/>

I get the following output of my program:
Voor de while
Voor instanceof
instance of: java.lang.String
instance package: package java.lang, Java Platform API Specification,
version 1.4
instance to string:

As you can see it's an instance of a String, but I expected an instance of a
Part. Can someone explain this?

When I look in the directory
-dir\ there's no file available. What do I do wrong? Has it something to
with AbstractXMLFormAction? I'm deploying under tomcat. Do I've to change
some settings of it?

Many thanks for your time!

Kind regards,
Robert Kromkamp

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message