cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Ramsay <>
Subject Re: File upload with flow (Wiki examples)
Date Mon, 15 Sep 2003 02:21:35 GMT
On Sun, Sep 14, 2003 at 10:01:05PM -0400, Geoff Howard wrote:
> Stephen Ramsay wrote:
> >On Sun, Sep 14, 2003 at 08:33:01AM -0400, Geoff Howard wrote:
> >
> >>Aha!  That wiki example has a problem I just noticed -- you shouldn't 
> >>return null here (I just corrected the wiki).  Use the corrected version 
> >>above - I'll explain below.

Well, Geoff, I just can't get it to work.  I'm no longer getting
404s, but it's still not uploading the file.

If you can stand it any longer, here's the rundown on what I've got.

First, the necessary switches have been turned on in web.xml:
upload-enabled is true, and the upload directory has been created (and enabled) with write
permission for all.

The HTML file looks like this:

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

<html xmlns="">
  <title>Start Page</title>

<body bgcolor="white">
	<form action="upload" method="POST" enctype="multipart/form-data">
		File: <input type="file" name="uploadfile" size="50"/><br/><br/>
		<input type="submit" name="action" value="Upload"/>

The action looks like this:

package edu.uga.english.cantor;


import java.util.Map;

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

public class SGUpload
  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);

			Part filePart = (PartOnDisk) request.get("uploadfile");

			if (filePart != null) {
				getLogger().debug("Uploaded file = " + filePart.getFileName());

			} else {

				getLogger().debug("File not found");


		return java.util.Collections.EMPTY_MAP;



(it resides in

And, finally, the sitemap contains these two directives:

	<map:action name="sg-upload" src="edu.uga.english.cantor.SGUpload"/>


<map:match pattern="upload">
	<map:act type="sg-upload">
		<map:read src="static/success.html" mime-type="text/html"/>

I'm making some kind of progress; when I hit upload it fires off the
success page.  However, there's still no file, and more crucially,
no log.

I'm probably going to hack away at it for another session or so
(using some ideas from the code you sent), but it's really not
looking good . . .

You've already gone way above and beyond the bounds of hackerly
helpfulness, but if you get a chance to draw your eye over the
above, I'd be much obliged.

One last thing, though.  I am runnning tomcat (on Linux) using the
mod_jk module for Apache.  Would this make any difference?  I can't
think of why it would (mod_jk is a pretty straightforward pass-it-on
type thing, and it works fine for the rest of my cocoon stuff), but
I thought I'd mention it . . .


Stephen Ramsay
Assistant Professor
Department of English
University of Georgia
PGP Public Key ID: 0xA38D7B11

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

View raw message