You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Stefan Riegel <st...@telig.de> on 2002/06/11 14:18:41 UTC
XSP Upload example - I do not understand
Hello, everybody,
I do not understand the XSP upload example. Yes, it works fine, but I would
like to understand as much as possible. I guess their is some "magic" behind
the scene.
I did some reading of the API Javadoc, but I'am still not experienced enough
reading source code. What to do? Should I give up learning Cocoon :-(
The example XSP-Source follows. I added comments about what I don't
understand.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- CVS: $Id: upload.xsp,v 1.3 2002/02/09 06:21:57 vgritsenko Exp $ -->
<!--
QUESTION: the namespace declarations for request, response and log are
not used and could be omitted? Is this correct?
-->
<xsp:page language="java"
xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-request="http://apache.org/xsp/request/2.0"
xmlns:xsp-response="http://apache.org/xsp/response/2.0"
xmlns:log="http://apache.org/xsp/log/2.0">
<xsp:structure>
<!--
QUESTION: Same with the XSPUtil import. Am I right?
-->
<xsp:include>org.apache.cocoon.components.language.markup.xsp.XSPUtil</xsp:i
nclude>
<xsp:include>org.apache.avalon.framework.context.ContextException</xsp:inclu
de>
</xsp:structure>
<!--
QUESTIONS: I do not understand this part. Who calls conceptualize?
Where does context
(org.apache.cocoon.generation.ServletGenerator.context?)
come from? And the get method of context? Their must be some "build in"
upload
functionality, please explain if You are patient enough.
-->
<xsp:logic>
File uploadDir = null;
/** Contextualize this class */
public void contextualize(Context context) throws ContextException {
uploadDir = (File) context.get(Constants.CONTEXT_UPLOAD_DIR);
}
</xsp:logic>
<page>
<title>This form allows you upload files</title>
<content>
<para>
<form method="post" enctype="multipart/form-data"
action="upload.xsp">
File: <input type="file" name="uploaded_file" size="50" />
<p><input type="submit" value="Upload File" /></p>
</form>
</para>
<para>
<ul>
<xsp:logic>
getLogger().debug("Dir=" + uploadDir);
String[] filelist = uploadDir.list();
<![CDATA[
getLogger().debug("List=" + filelist.length);
for (int i = 0; i < filelist.length; i++) {
getLogger().debug("File [" + i + "]=" + filelist[i]);
]]>
<li>
<xsp:expr>filelist[i]</xsp:expr>
</li>
<![CDATA[
}
]]>
</xsp:logic>
</ul>
</para>
<para>Brought to you by Cocoon at <xsp:expr>new
Date()</xsp:expr>.</para>
</content>
</page>
</xsp:page>
Thank You.
Regards
Stefan
--
Stefan Riegel
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: Vadim : RE: XSP Upload example - I do not understand
Posted by Nicola Ken Barozzi <ni...@apache.org>.
Jeroen ter Voorde wrote:
> Hi,
>
> You can use an action to move the attachment to where you want. Here's how:
>
> http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=101878098524370&w=2
Or fix the upload mechanism ;-)
Having to pass upload stuff conf to Cocoon directly is an ugly hack,
that nobody ever took time to change.
If you are willing...
--
Nicola Ken Barozzi nicolaken@apache.org
- verba volant, scripta manent -
(discussions get forgotten, just code remains)
---------------------------------------------------------------------
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: Vadim : RE: XSP Upload example - I do not understand
Posted by Jeroen ter Voorde <j....@home.nl>.
Hi,
You can use an action to move the attachment to where you want. Here's how:
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=101878098524370&w=2
Jeroen
----- Original Message -----
From: "Chitharanjan Das" <cd...@accordiasys.com>
To: <co...@xml.apache.org>
Sent: Wednesday, June 12, 2002 12:32 AM
Subject: RE: Vadim : RE: XSP Upload example - I do not understand
>
> Thanks a million....
>
> I understand it now...
>
> Let me try to clarify
>
> 1. Upload directory is read from init parameter. Hence it is kinda fixed
> .
> 2. We do not get the control of uploaded files.
> As soon as the Cocoon gets a request. The request is processed
> for Multipart request processing. Is this how it has to be processed ?
> The only way to change this is to provide my own version of multi-part
> request processing factory. However, the problem is that you can have
> utmost one kind of behaviour.
> 3. In my implementation, I need to store the files in different
> directories, depending upon the type of files uploaded. How do you
> suggest I go ant it...
>
>
> Thanks in advance,
> Chiths
>
>
>
>
>
>
>
>
>
> -----Original Message-----
> From: Vadim Gritsenko [mailto:vadim.gritsenko@verizon.net]
> Sent: Tuesday, June 11, 2002 1:18 PM
> To: cocoon-users@xml.apache.org
> Subject: RE: Vadim : RE: XSP Upload example - I do not understand
>
> > From: Chitharanjan Das [mailto:cdas@accordiasys.com]
> >
> > Hello Vadim...
> >
> > If you might explain the upload functionality .......
> >
> > 1. Form with multipart data is submitted to upload.xsp
> > 2. The form parameters have to be processed. I changed the form
> variable
> > name from uploaded_file to files and still it works.
> > 3. If I have to do additional processing like throw error if the file
> > exists or the file needs to be stored in a specific pattern say
> > $upload_directory/<date>/<user>/<filename>_uniqueId. How can I
> customize
> > it.
>
> Look into the source. Start with CocoonServlet:
>
> HttpServletRequest request =
> RequestFactory.getRequestFactory(requestFactoryClass).getServletRequest(
> req,
>
> CocoonServlet.SAVE_UPLOADED_FILES_TO_DISK,
> this.uploadDir,
> CocoonServlet.ALLOW_OVERWRITE,
> CocoonServlet.SILENTLY_RENAME,
> this.maxUploadSize);
>
>
> > 4. If there are additional form elements, how do I process them.
> > 5. Where is the upload functionality being invoked.. Its kind a vague
> > (for my intellect).
>
> From the servlet, see line(s) above.
>
> Vadim
>
>
> >
> > Thanks in Advance,
> > Chiths
> >
> >
> > -----Original Message-----
> > From: Vadim Gritsenko [mailto:vadim.gritsenko@verizon.net]
> > Sent: Tuesday, June 11, 2002 6:51 AM
> > To: cocoon-users@xml.apache.org; stefan.riegel@telig.de
> > Subject: RE: XSP Upload example - I do not understand
> >
> > > From: Stefan Riegel [mailto:stefan.riegel@telig.de]
> > >
> > > Hello, everybody,
> > >
> > > I do not understand the XSP upload example. Yes, it works fine, but
> I
> > would
> > > like to understand as much as possible. I guess their is some
> "magic"
> > behind
> > > the scene.
> > >
> > > I did some reading of the API Javadoc, but I'am still not
> experienced
> > enough
> > > reading source code. What to do? Should I give up learning Cocoon
> :-(
> >
> > Try reading Java source code generated from the XSP.
> >
> >
> > > The example XSP-Source follows. I added comments about what I don't
> > > understand.
> > >
> > >
> > > <?xml version="1.0" encoding="ISO-8859-1"?>
> > >
> > > <!-- CVS: $Id: upload.xsp,v 1.3 2002/02/09 06:21:57 vgritsenko Exp $
> > -->
> > >
> > >
> > > <!--
> > > QUESTION: the namespace declarations for request, response and log
> are
> > > not used and could be omitted? Is this correct?
> > > -->
> >
> > If not used then can be omitted.
> >
> >
> > > <xsp:page language="java"
> > > xmlns:xsp="http://apache.org/xsp"
> > > xmlns:xsp-request="http://apache.org/xsp/request/2.0"
> > > xmlns:xsp-response="http://apache.org/xsp/response/2.0"
> > > xmlns:log="http://apache.org/xsp/log/2.0">
> > >
> > > <xsp:structure>
> > > <!--
> > > QUESTION: Same with the XSPUtil import. Am I right?
> > > -->
> >
> > Same.
> >
> >
> > >
> >
> <xsp:include>org.apache.cocoon.components.language.markup.xsp.XSPUtil</x
> > sp:i
> > > nclude>
> > >
> > >
> >
> <xsp:include>org.apache.avalon.framework.context.ContextException</xsp:i
> > nclu
> > > de>
> > > </xsp:structure>
> > >
> > > <!--
> > > QUESTIONS: I do not understand this part. Who calls conceptualize?
> >
> > Contextualize. Avalon does.
> > See
> >
> http://jakarta.apache.org/avalon/framework/reference-the-lifecycle.html
> >
> >
> > > Where does context
> > > (org.apache.cocoon.generation.ServletGenerator.context?)
> > > come from?
> >
> > Avalon gives.
> >
> http://jakarta.apache.org/avalon/api/org/apache/avalon/framework/context
> > /Context.html
> >
> >
> > > And the get method of context?
> >
> > See link above.
> >
> >
> > > Their must be some "build in"
> > > upload
> > > functionality, please explain if You are patient enough.
> >
> > Yes, there is. And it uses maybeupload library, or Multipart request
> > parser. See org.apache.cocoon.components.request package.
> >
> > Vadim
> >
> >
> > > -->
> > > <xsp:logic>
> > > File uploadDir = null;
> > > /** Contextualize this class */
> > > public void contextualize(Context context) throws ContextException
> {
> > > uploadDir = (File) context.get(Constants.CONTEXT_UPLOAD_DIR);
> > > }
> > > </xsp:logic>
> > >
> > > <page>
> > > <title>This form allows you upload files</title>
> > > <content>
> > > <para>
> > > <form method="post" enctype="multipart/form-data"
> > > action="upload.xsp">
> > > File: <input type="file" name="uploaded_file" size="50" />
> > > <p><input type="submit" value="Upload File" /></p>
> > > </form>
> > > </para>
> > > <para>
> > > <ul>
> > > <xsp:logic>
> > > getLogger().debug("Dir=" + uploadDir);
> > > String[] filelist = uploadDir.list();
> > > <![CDATA[
> > > getLogger().debug("List=" + filelist.length);
> > > for (int i = 0; i < filelist.length; i++) {
> > > getLogger().debug("File [" + i + "]=" + filelist[i]);
> > > ]]>
> > > <li>
> > > <xsp:expr>filelist[i]</xsp:expr>
> > > </li>
> > > <![CDATA[
> > > }
> > > ]]>
> > > </xsp:logic>
> > > </ul>
> > > </para>
> > > <para>Brought to you by Cocoon at <xsp:expr>new
> > > Date()</xsp:expr>.</para>
> > >
> > > </content>
> > > </page>
> > > </xsp:page>
> > >
> > >
> > > Thank You.
> > >
> > > Regards
> > > Stefan
> > > --
> > >
> > > Stefan Riegel
> >
> >
> > ---------------------------------------------------------------------
> > Please check that your question has not already been answered in the
> > FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
> >
> > To unsubscribe, e-mail: <co...@xml.apache.org>
> > For additional commands, e-mail: <co...@xml.apache.org>
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > Please check that your question has not already been answered in the
> > FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
> >
> > To unsubscribe, e-mail: <co...@xml.apache.org>
> > For additional commands, e-mail: <co...@xml.apache.org>
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
RE: Vadim : RE: XSP Upload example - I do not understand
Posted by Vadim Gritsenko <va...@verizon.net>.
> From: Chitharanjan Das [mailto:cdas@accordiasys.com]
>
>
> Thanks a million....
>
> I understand it now...
>
> Let me try to clarify
>
> 1. Upload directory is read from init parameter. Hence it is kinda
fixed
> .
> 2. We do not get the control of uploaded files.
> As soon as the Cocoon gets a request. The request is processed
> for Multipart request processing. Is this how it has to be processed ?
> The only way to change this is to provide my own version of multi-part
> request processing factory. However, the problem is that you can have
> utmost one kind of behaviour.
> 3. In my implementation, I need to store the files in different
> directories, depending upon the type of files uploaded. How do you
> suggest I go ant it...
File.renameTo() should work like move, isn't it?
Vadim
> Thanks in advance,
> Chiths
>
>
>
>
>
>
>
>
>
> -----Original Message-----
> From: Vadim Gritsenko [mailto:vadim.gritsenko@verizon.net]
> Sent: Tuesday, June 11, 2002 1:18 PM
> To: cocoon-users@xml.apache.org
> Subject: RE: Vadim : RE: XSP Upload example - I do not understand
>
> > From: Chitharanjan Das [mailto:cdas@accordiasys.com]
> >
> > Hello Vadim...
> >
> > If you might explain the upload functionality .......
> >
> > 1. Form with multipart data is submitted to upload.xsp
> > 2. The form parameters have to be processed. I changed the form
> > variable
> > name from uploaded_file to files and still it works.
> > 3. If I have to do additional processing like throw error if the
file
> > exists or the file needs to be stored in a specific pattern say
> > $upload_directory/<date>/<user>/<filename>_uniqueId. How can I
> > customize
> > it.
>
> Look into the source. Start with CocoonServlet:
>
> HttpServletRequest request =
>
RequestFactory.getRequestFactory(requestFactoryClass).getServletRequest(
> req,
>
> CocoonServlet.SAVE_UPLOADED_FILES_TO_DISK,
> this.uploadDir,
>
CocoonServlet.ALLOW_OVERWRITE,
>
CocoonServlet.SILENTLY_RENAME,
> this.maxUploadSize);
>
>
> > 4. If there are additional form elements, how do I process them.
> > 5. Where is the upload functionality being invoked.. Its kind a
vague
> > (for my intellect).
>
> From the servlet, see line(s) above.
>
> Vadim
...
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
RE: Vadim : RE: XSP Upload example - I do not understand
Posted by Chitharanjan Das <cd...@accordiasys.com>.
Thanks a million....
I understand it now...
Let me try to clarify
1. Upload directory is read from init parameter. Hence it is kinda fixed
.
2. We do not get the control of uploaded files.
As soon as the Cocoon gets a request. The request is processed
for Multipart request processing. Is this how it has to be processed ?
The only way to change this is to provide my own version of multi-part
request processing factory. However, the problem is that you can have
utmost one kind of behaviour.
3. In my implementation, I need to store the files in different
directories, depending upon the type of files uploaded. How do you
suggest I go ant it...
Thanks in advance,
Chiths
-----Original Message-----
From: Vadim Gritsenko [mailto:vadim.gritsenko@verizon.net]
Sent: Tuesday, June 11, 2002 1:18 PM
To: cocoon-users@xml.apache.org
Subject: RE: Vadim : RE: XSP Upload example - I do not understand
> From: Chitharanjan Das [mailto:cdas@accordiasys.com]
>
> Hello Vadim...
>
> If you might explain the upload functionality .......
>
> 1. Form with multipart data is submitted to upload.xsp
> 2. The form parameters have to be processed. I changed the form
variable
> name from uploaded_file to files and still it works.
> 3. If I have to do additional processing like throw error if the file
> exists or the file needs to be stored in a specific pattern say
> $upload_directory/<date>/<user>/<filename>_uniqueId. How can I
customize
> it.
Look into the source. Start with CocoonServlet:
HttpServletRequest request =
RequestFactory.getRequestFactory(requestFactoryClass).getServletRequest(
req,
CocoonServlet.SAVE_UPLOADED_FILES_TO_DISK,
this.uploadDir,
CocoonServlet.ALLOW_OVERWRITE,
CocoonServlet.SILENTLY_RENAME,
this.maxUploadSize);
> 4. If there are additional form elements, how do I process them.
> 5. Where is the upload functionality being invoked.. Its kind a vague
> (for my intellect).
>From the servlet, see line(s) above.
Vadim
>
> Thanks in Advance,
> Chiths
>
>
> -----Original Message-----
> From: Vadim Gritsenko [mailto:vadim.gritsenko@verizon.net]
> Sent: Tuesday, June 11, 2002 6:51 AM
> To: cocoon-users@xml.apache.org; stefan.riegel@telig.de
> Subject: RE: XSP Upload example - I do not understand
>
> > From: Stefan Riegel [mailto:stefan.riegel@telig.de]
> >
> > Hello, everybody,
> >
> > I do not understand the XSP upload example. Yes, it works fine, but
I
> would
> > like to understand as much as possible. I guess their is some
"magic"
> behind
> > the scene.
> >
> > I did some reading of the API Javadoc, but I'am still not
experienced
> enough
> > reading source code. What to do? Should I give up learning Cocoon
:-(
>
> Try reading Java source code generated from the XSP.
>
>
> > The example XSP-Source follows. I added comments about what I don't
> > understand.
> >
> >
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> >
> > <!-- CVS: $Id: upload.xsp,v 1.3 2002/02/09 06:21:57 vgritsenko Exp $
> -->
> >
> >
> > <!--
> > QUESTION: the namespace declarations for request, response and log
are
> > not used and could be omitted? Is this correct?
> > -->
>
> If not used then can be omitted.
>
>
> > <xsp:page language="java"
> > xmlns:xsp="http://apache.org/xsp"
> > xmlns:xsp-request="http://apache.org/xsp/request/2.0"
> > xmlns:xsp-response="http://apache.org/xsp/response/2.0"
> > xmlns:log="http://apache.org/xsp/log/2.0">
> >
> > <xsp:structure>
> > <!--
> > QUESTION: Same with the XSPUtil import. Am I right?
> > -->
>
> Same.
>
>
> >
>
<xsp:include>org.apache.cocoon.components.language.markup.xsp.XSPUtil</x
> sp:i
> > nclude>
> >
> >
>
<xsp:include>org.apache.avalon.framework.context.ContextException</xsp:i
> nclu
> > de>
> > </xsp:structure>
> >
> > <!--
> > QUESTIONS: I do not understand this part. Who calls conceptualize?
>
> Contextualize. Avalon does.
> See
>
http://jakarta.apache.org/avalon/framework/reference-the-lifecycle.html
>
>
> > Where does context
> > (org.apache.cocoon.generation.ServletGenerator.context?)
> > come from?
>
> Avalon gives.
>
http://jakarta.apache.org/avalon/api/org/apache/avalon/framework/context
> /Context.html
>
>
> > And the get method of context?
>
> See link above.
>
>
> > Their must be some "build in"
> > upload
> > functionality, please explain if You are patient enough.
>
> Yes, there is. And it uses maybeupload library, or Multipart request
> parser. See org.apache.cocoon.components.request package.
>
> Vadim
>
>
> > -->
> > <xsp:logic>
> > File uploadDir = null;
> > /** Contextualize this class */
> > public void contextualize(Context context) throws ContextException
{
> > uploadDir = (File) context.get(Constants.CONTEXT_UPLOAD_DIR);
> > }
> > </xsp:logic>
> >
> > <page>
> > <title>This form allows you upload files</title>
> > <content>
> > <para>
> > <form method="post" enctype="multipart/form-data"
> > action="upload.xsp">
> > File: <input type="file" name="uploaded_file" size="50" />
> > <p><input type="submit" value="Upload File" /></p>
> > </form>
> > </para>
> > <para>
> > <ul>
> > <xsp:logic>
> > getLogger().debug("Dir=" + uploadDir);
> > String[] filelist = uploadDir.list();
> > <![CDATA[
> > getLogger().debug("List=" + filelist.length);
> > for (int i = 0; i < filelist.length; i++) {
> > getLogger().debug("File [" + i + "]=" + filelist[i]);
> > ]]>
> > <li>
> > <xsp:expr>filelist[i]</xsp:expr>
> > </li>
> > <![CDATA[
> > }
> > ]]>
> > </xsp:logic>
> > </ul>
> > </para>
> > <para>Brought to you by Cocoon at <xsp:expr>new
> > Date()</xsp:expr>.</para>
> >
> > </content>
> > </page>
> > </xsp:page>
> >
> >
> > Thank You.
> >
> > Regards
> > Stefan
> > --
> >
> > Stefan Riegel
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
RE: Vadim : RE: XSP Upload example - I do not understand
Posted by Vadim Gritsenko <va...@verizon.net>.
> From: Chitharanjan Das [mailto:cdas@accordiasys.com]
>
> Hello Vadim...
>
> If you might explain the upload functionality .......
>
> 1. Form with multipart data is submitted to upload.xsp
> 2. The form parameters have to be processed. I changed the form
variable
> name from uploaded_file to files and still it works.
> 3. If I have to do additional processing like throw error if the file
> exists or the file needs to be stored in a specific pattern say
> $upload_directory/<date>/<user>/<filename>_uniqueId. How can I
customize
> it.
Look into the source. Start with CocoonServlet:
HttpServletRequest request =
RequestFactory.getRequestFactory(requestFactoryClass).getServletRequest(
req,
CocoonServlet.SAVE_UPLOADED_FILES_TO_DISK,
this.uploadDir,
CocoonServlet.ALLOW_OVERWRITE,
CocoonServlet.SILENTLY_RENAME,
this.maxUploadSize);
> 4. If there are additional form elements, how do I process them.
> 5. Where is the upload functionality being invoked.. Its kind a vague
> (for my intellect).
>From the servlet, see line(s) above.
Vadim
>
> Thanks in Advance,
> Chiths
>
>
> -----Original Message-----
> From: Vadim Gritsenko [mailto:vadim.gritsenko@verizon.net]
> Sent: Tuesday, June 11, 2002 6:51 AM
> To: cocoon-users@xml.apache.org; stefan.riegel@telig.de
> Subject: RE: XSP Upload example - I do not understand
>
> > From: Stefan Riegel [mailto:stefan.riegel@telig.de]
> >
> > Hello, everybody,
> >
> > I do not understand the XSP upload example. Yes, it works fine, but
I
> would
> > like to understand as much as possible. I guess their is some
"magic"
> behind
> > the scene.
> >
> > I did some reading of the API Javadoc, but I'am still not
experienced
> enough
> > reading source code. What to do? Should I give up learning Cocoon
:-(
>
> Try reading Java source code generated from the XSP.
>
>
> > The example XSP-Source follows. I added comments about what I don't
> > understand.
> >
> >
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> >
> > <!-- CVS: $Id: upload.xsp,v 1.3 2002/02/09 06:21:57 vgritsenko Exp $
> -->
> >
> >
> > <!--
> > QUESTION: the namespace declarations for request, response and log
are
> > not used and could be omitted? Is this correct?
> > -->
>
> If not used then can be omitted.
>
>
> > <xsp:page language="java"
> > xmlns:xsp="http://apache.org/xsp"
> > xmlns:xsp-request="http://apache.org/xsp/request/2.0"
> > xmlns:xsp-response="http://apache.org/xsp/response/2.0"
> > xmlns:log="http://apache.org/xsp/log/2.0">
> >
> > <xsp:structure>
> > <!--
> > QUESTION: Same with the XSPUtil import. Am I right?
> > -->
>
> Same.
>
>
> >
>
<xsp:include>org.apache.cocoon.components.language.markup.xsp.XSPUtil</x
> sp:i
> > nclude>
> >
> >
>
<xsp:include>org.apache.avalon.framework.context.ContextException</xsp:i
> nclu
> > de>
> > </xsp:structure>
> >
> > <!--
> > QUESTIONS: I do not understand this part. Who calls conceptualize?
>
> Contextualize. Avalon does.
> See
>
http://jakarta.apache.org/avalon/framework/reference-the-lifecycle.html
>
>
> > Where does context
> > (org.apache.cocoon.generation.ServletGenerator.context?)
> > come from?
>
> Avalon gives.
>
http://jakarta.apache.org/avalon/api/org/apache/avalon/framework/context
> /Context.html
>
>
> > And the get method of context?
>
> See link above.
>
>
> > Their must be some "build in"
> > upload
> > functionality, please explain if You are patient enough.
>
> Yes, there is. And it uses maybeupload library, or Multipart request
> parser. See org.apache.cocoon.components.request package.
>
> Vadim
>
>
> > -->
> > <xsp:logic>
> > File uploadDir = null;
> > /** Contextualize this class */
> > public void contextualize(Context context) throws ContextException
{
> > uploadDir = (File) context.get(Constants.CONTEXT_UPLOAD_DIR);
> > }
> > </xsp:logic>
> >
> > <page>
> > <title>This form allows you upload files</title>
> > <content>
> > <para>
> > <form method="post" enctype="multipart/form-data"
> > action="upload.xsp">
> > File: <input type="file" name="uploaded_file" size="50" />
> > <p><input type="submit" value="Upload File" /></p>
> > </form>
> > </para>
> > <para>
> > <ul>
> > <xsp:logic>
> > getLogger().debug("Dir=" + uploadDir);
> > String[] filelist = uploadDir.list();
> > <![CDATA[
> > getLogger().debug("List=" + filelist.length);
> > for (int i = 0; i < filelist.length; i++) {
> > getLogger().debug("File [" + i + "]=" + filelist[i]);
> > ]]>
> > <li>
> > <xsp:expr>filelist[i]</xsp:expr>
> > </li>
> > <![CDATA[
> > }
> > ]]>
> > </xsp:logic>
> > </ul>
> > </para>
> > <para>Brought to you by Cocoon at <xsp:expr>new
> > Date()</xsp:expr>.</para>
> >
> > </content>
> > </page>
> > </xsp:page>
> >
> >
> > Thank You.
> >
> > Regards
> > Stefan
> > --
> >
> > Stefan Riegel
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Vadim : RE: XSP Upload example - I do not understand
Posted by Chitharanjan Das <cd...@accordiasys.com>.
Hello Vadim...
If you might explain the upload functionality .......
1. Form with multipart data is submitted to upload.xsp
2. The form parameters have to be processed. I changed the form variable
name from uploaded_file to files and still it works.
3. If I have to do additional processing like throw error if the file
exists or the file needs to be stored in a specific pattern say
$upload_directory/<date>/<user>/<filename>_uniqueId. How can I customize
it.
4. If there are additional form elements, how do I process them.
5. Where is the upload functionality being invoked.. Its kind a vague
(for my intellect).
Thanks in Advance,
Chiths
-----Original Message-----
From: Vadim Gritsenko [mailto:vadim.gritsenko@verizon.net]
Sent: Tuesday, June 11, 2002 6:51 AM
To: cocoon-users@xml.apache.org; stefan.riegel@telig.de
Subject: RE: XSP Upload example - I do not understand
> From: Stefan Riegel [mailto:stefan.riegel@telig.de]
>
> Hello, everybody,
>
> I do not understand the XSP upload example. Yes, it works fine, but I
would
> like to understand as much as possible. I guess their is some "magic"
behind
> the scene.
>
> I did some reading of the API Javadoc, but I'am still not experienced
enough
> reading source code. What to do? Should I give up learning Cocoon :-(
Try reading Java source code generated from the XSP.
> The example XSP-Source follows. I added comments about what I don't
> understand.
>
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <!-- CVS: $Id: upload.xsp,v 1.3 2002/02/09 06:21:57 vgritsenko Exp $
-->
>
>
> <!--
> QUESTION: the namespace declarations for request, response and log are
> not used and could be omitted? Is this correct?
> -->
If not used then can be omitted.
> <xsp:page language="java"
> xmlns:xsp="http://apache.org/xsp"
> xmlns:xsp-request="http://apache.org/xsp/request/2.0"
> xmlns:xsp-response="http://apache.org/xsp/response/2.0"
> xmlns:log="http://apache.org/xsp/log/2.0">
>
> <xsp:structure>
> <!--
> QUESTION: Same with the XSPUtil import. Am I right?
> -->
Same.
>
<xsp:include>org.apache.cocoon.components.language.markup.xsp.XSPUtil</x
sp:i
> nclude>
>
>
<xsp:include>org.apache.avalon.framework.context.ContextException</xsp:i
nclu
> de>
> </xsp:structure>
>
> <!--
> QUESTIONS: I do not understand this part. Who calls conceptualize?
Contextualize. Avalon does.
See
http://jakarta.apache.org/avalon/framework/reference-the-lifecycle.html
> Where does context
> (org.apache.cocoon.generation.ServletGenerator.context?)
> come from?
Avalon gives.
http://jakarta.apache.org/avalon/api/org/apache/avalon/framework/context
/Context.html
> And the get method of context?
See link above.
> Their must be some "build in"
> upload
> functionality, please explain if You are patient enough.
Yes, there is. And it uses maybeupload library, or Multipart request
parser. See org.apache.cocoon.components.request package.
Vadim
> -->
> <xsp:logic>
> File uploadDir = null;
> /** Contextualize this class */
> public void contextualize(Context context) throws ContextException {
> uploadDir = (File) context.get(Constants.CONTEXT_UPLOAD_DIR);
> }
> </xsp:logic>
>
> <page>
> <title>This form allows you upload files</title>
> <content>
> <para>
> <form method="post" enctype="multipart/form-data"
> action="upload.xsp">
> File: <input type="file" name="uploaded_file" size="50" />
> <p><input type="submit" value="Upload File" /></p>
> </form>
> </para>
> <para>
> <ul>
> <xsp:logic>
> getLogger().debug("Dir=" + uploadDir);
> String[] filelist = uploadDir.list();
> <![CDATA[
> getLogger().debug("List=" + filelist.length);
> for (int i = 0; i < filelist.length; i++) {
> getLogger().debug("File [" + i + "]=" + filelist[i]);
> ]]>
> <li>
> <xsp:expr>filelist[i]</xsp:expr>
> </li>
> <![CDATA[
> }
> ]]>
> </xsp:logic>
> </ul>
> </para>
> <para>Brought to you by Cocoon at <xsp:expr>new
> Date()</xsp:expr>.</para>
>
> </content>
> </page>
> </xsp:page>
>
>
> Thank You.
>
> Regards
> Stefan
> --
>
> Stefan Riegel
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
RE: XSP Upload example - I do not understand
Posted by Vadim Gritsenko <va...@verizon.net>.
> From: Stefan Riegel [mailto:stefan.riegel@telig.de]
>
> Hello, everybody,
>
> I do not understand the XSP upload example. Yes, it works fine, but I
would
> like to understand as much as possible. I guess their is some "magic"
behind
> the scene.
>
> I did some reading of the API Javadoc, but I'am still not experienced
enough
> reading source code. What to do? Should I give up learning Cocoon :-(
Try reading Java source code generated from the XSP.
> The example XSP-Source follows. I added comments about what I don't
> understand.
>
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <!-- CVS: $Id: upload.xsp,v 1.3 2002/02/09 06:21:57 vgritsenko Exp $
-->
>
>
> <!--
> QUESTION: the namespace declarations for request, response and log are
> not used and could be omitted? Is this correct?
> -->
If not used then can be omitted.
> <xsp:page language="java"
> xmlns:xsp="http://apache.org/xsp"
> xmlns:xsp-request="http://apache.org/xsp/request/2.0"
> xmlns:xsp-response="http://apache.org/xsp/response/2.0"
> xmlns:log="http://apache.org/xsp/log/2.0">
>
> <xsp:structure>
> <!--
> QUESTION: Same with the XSPUtil import. Am I right?
> -->
Same.
>
<xsp:include>org.apache.cocoon.components.language.markup.xsp.XSPUtil</x
sp:i
> nclude>
>
>
<xsp:include>org.apache.avalon.framework.context.ContextException</xsp:i
nclu
> de>
> </xsp:structure>
>
> <!--
> QUESTIONS: I do not understand this part. Who calls conceptualize?
Contextualize. Avalon does.
See
http://jakarta.apache.org/avalon/framework/reference-the-lifecycle.html
> Where does context
> (org.apache.cocoon.generation.ServletGenerator.context?)
> come from?
Avalon gives.
http://jakarta.apache.org/avalon/api/org/apache/avalon/framework/context
/Context.html
> And the get method of context?
See link above.
> Their must be some "build in"
> upload
> functionality, please explain if You are patient enough.
Yes, there is. And it uses maybeupload library, or Multipart request
parser. See org.apache.cocoon.components.request package.
Vadim
> -->
> <xsp:logic>
> File uploadDir = null;
> /** Contextualize this class */
> public void contextualize(Context context) throws ContextException {
> uploadDir = (File) context.get(Constants.CONTEXT_UPLOAD_DIR);
> }
> </xsp:logic>
>
> <page>
> <title>This form allows you upload files</title>
> <content>
> <para>
> <form method="post" enctype="multipart/form-data"
> action="upload.xsp">
> File: <input type="file" name="uploaded_file" size="50" />
> <p><input type="submit" value="Upload File" /></p>
> </form>
> </para>
> <para>
> <ul>
> <xsp:logic>
> getLogger().debug("Dir=" + uploadDir);
> String[] filelist = uploadDir.list();
> <![CDATA[
> getLogger().debug("List=" + filelist.length);
> for (int i = 0; i < filelist.length; i++) {
> getLogger().debug("File [" + i + "]=" + filelist[i]);
> ]]>
> <li>
> <xsp:expr>filelist[i]</xsp:expr>
> </li>
> <![CDATA[
> }
> ]]>
> </xsp:logic>
> </ul>
> </para>
> <para>Brought to you by Cocoon at <xsp:expr>new
> Date()</xsp:expr>.</para>
>
> </content>
> </page>
> </xsp:page>
>
>
> Thank You.
>
> Regards
> Stefan
> --
>
> Stefan Riegel
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>