You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by steph <pr...@free.fr> on 2004/02/24 01:16:03 UTC
[file upload with XSP-actions] first try
Hello,
As my application need to do an upload, I am searching how to do this
with cocoon (2.1.4 with a GNU/Linux box).
I saw on the wiki that the 2 recommended ways to do that are Actions and
flows. But , as I don't use flows (for my co-workers javascript is a
"patching" langage), I'd like to do this with actions.
As a beginner, I had a look at how actions run and this is what I
understood (correct me if i'm wrong).
- actions must be wrote in cocoon sources
- each time I'd like to create a new action I have a to re compile
cocoon.
As I've got an "old" 300 Mhz computer, I won't be annoying waiting 30
minutes (whithout cocoon/postgresql configuration) to see if my action
works correctly (and then re run the compilation 'cause it does never
work at first time :) ).
This is why I choose to try XSP-actions.
Even if the wiki page was pretty I still don't know how to start writing
it.
this is a first try (that does not work!):
/************/
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page language="java"
xmlns:xsp="http://apache.org/xsp"
xmlns:action="http://apache.org/cocoon/action/1.0"
xmlns:xsp-request="http://apache.org/xsp/request/2.0">
<xsp:structure>
<xsp:include>java.util.*</xsp:include>
<xsp:include>java.io.File</xsp:include>
<xsp:include>java.util.Collections</xsp:include>
<xsp:include>java.util.Map</xsp:include>
<xsp:include>org.apache.cocoon.environment.*</xsp:include>
<xsp:include>org.apache.cocoon.components.request.*</xsp:include>
</xsp:structure>
<xsp:logic>
try
{
FilePart filePart = (FilePart) request.get("uploaded_file");
File file = ((FilePartFile)filePart).getFile();
System.out.println("Uploaded file = "+file.getCanonicalPath()+"\n");
}
catch(Exception e)
{
e.printStackTrace() ;
<action:set-failure/>
}
</xsp:logic>
</xsp:page>
/***********************/
...
<map:components>
<map:actions>
<map:action
logger="sitemap.action.xsp-action"
name="xsp-action"
src="org.apache.cocoon.acting.ServerPagesAction"/>
</map:actions>
...
<map:match pattern="affichage">
<map:act type ="xsp-action" src="FileUpload.xsp">
<map:transform src="affichage.xsl">
<map:parameter name="use-request-parameters" value="true"/>
</map:transform>
<map:serialize type="html"/>
</map:act>
</map:match>
/*****************/
The first goal of this little XSP-action is to print the name of the
uploaded page on the shell where I run cocoon (as a servlet).
It seems that I can't use the FilePart type.
(I can post my error message if needed but it's rather long and I think
I made comprehension errors before syntax ones)
The final Application will be able to upload a file, put it in the
correct directory and save its path in database. (I guess that actions
could do this)
Thank you in advance,
Stephane
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [file upload with XSP-actions] first try
Posted by Askild Aaberg Olsen <as...@xangeli.com>.
> Hello,
>
> The first goal of this little XSP-action is to print the name
> of the uploaded page on the shell where I run cocoon (as a
> servlet). It seems that I can't use the FilePart type.
What if you use:
PartOnDisk part = (PartOnDisk) request.get("upload_file") ?
Askild
-
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org