cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From St├ęphane Delort <delor...@free.fr>
Subject [file upload] flow, actions and ........ XSP ?
Date Tue, 24 Feb 2004 18:16:11 GMT
Thanks to Askild; I finaly reached my goal.

but I for doing this file upload I uses neither flows nor actions, but a
"simple" XSP page.  
(source code copied at the end)

I would like to know the differencies between doing that with actions,
flows and XSP. 


thanks in advance,
Stephane
 


/***********************  XSP file  *****************************
<?xml version="1.0" encoding="ISO-8859-1"?>

<xsp:page language="java"
          xmlns:xsp="http://apache.org/xsp"
	  xmlns:xsp-request="http://apache.org/xsp/request/2.0"
	  xmlns:esql="http://apache.org/cocoon/SQL/v2">

<xsp:structure>
<xsp:include>java.util.*</xsp:include>
<xsp:include>java.io.File</xsp:include>
<xsp:include>java.io.FileOutputStream</xsp:include>
<xsp:include>java.io.FileInputStream</xsp:include>
<xsp:include>java.util.Collections</xsp:include>
<xsp:include>java.util.Map</xsp:include>
<xsp:include>org.apache.cocoon.servlet.multipart.*</xsp:include>
<xsp:include>java.lang.String</xsp:include>
</xsp:structure>

<page>
<title>path :</title>

<xsp:logic>
  Part   part = (Part) request.get("uploaded_file");
  String res  = part.getUploadName() ;

  <![CDATA[ if(part!=null && res.endsWith(".jpg"))]]>
  {
    <result>
      Le fichier "<xsp:expr>res</xsp:expr>" est une image jpg.
    </result>
    <result><xsp:expr> part.getMimeType()</xsp:expr></result>
    try
    {
   <![CDATA[ byte[] tab = new byte [1024]; ]]>
      FileOutputStream sortie = new
FileOutputStream("build/webapp/www/xsp/fileUpload/sortie.jpg");
      InputStream entree = part.getInputStream();
      <![CDATA[ while( entree.read(tab) > 0 ) ]]>
      {
        sortie.write(tab);
      }
      entree.close();
      sortie.close();
    }
    catch(Exception e)
    {}
  }
  else
  {
   <result>No image or not an image file.</result>
  }
</xsp:logic>

</page>
</xsp:page>



/*********************** Sitemap *******************/
......

<map:match pattern="affichage">
  <map:generate src="affichage.xsp" type="serverpages"/>
  <map:transform src="affichage.xsl">
    <map:parameter name="use-request-parameters" value="true"/>
  </map:transform>
  <map:serialize type="html"/>
</map:match>
...


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


Mime
View raw message