You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Kogan Irina <Ir...@mchp.siemens.de> on 2003/05/16 17:58:34 UTC

RE: File upload in cocoon: org.apache.cocoon.components.request.m ultipart.FilePart is missing.

Thank you very much for your answer!

I have written the file UploadTest.jar (for now doing pretty much nothing)
and put the class UploadTest into the package upload.test:

package upload.test;

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

import java.util.Map;
import java.io.File;

public class UploadTest 
  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);
        // FilePart filePart = (FilePart) request.get("uploaded_file");
        Part part = (Part) request.get("blah");

        // File file = ((PartFile)filePart).getFile();

        // getLogger().debug("Uploaded file = " + file.getCanonicalPath());
        // here you can open an InputStream on the file or whatever
        // you may also want to delete the file after using it
        return null;
    }
}

Then I compile this file (no errors encountered) and create UploadTest.jar
from UploadTest.class.  Then I put this file into lib directory of cocoon in
TomCat where all jar files are.

Then to the main sitemap (for all samples) I add this action
<map:action name="upload" src="upload.test.UploadTest"/>

And I have the following in the sitemap in my test sample:

<map:match pattern="*.html">
    <map:read src="{1}.html"/>
</map:match>
		    
<map:match pattern="file">
     <map:act type="upload" src="optional src"> 
     	   <map:generate type="html" src="success.html"/>
     </map:act>
     <map:serialize/>
</map:match>

When I go to the page http://localhost:8080/cocoon/samples/test/upload.html,
I get the following error message:

Internal Server Error


Message: null

Description: No details available.

Sender: org.apache.cocoon.servlet.CocoonServlet

Source: Cocoon Servlet

Request URI

   samples/test/upload.html

cause

   upload.test.UploadTest

request-uri

   /cocoon/samples/test/upload.html


Do you know what is wrong?  Thanks a million!

Have a good weekend!

Irina.

> -----Original Message-----
> From: Geoff Howard [mailto:cocoon@leverageweb.com]
> Sent: Freitag, 16. Mai 2003 04:41
> To: cocoon-users@xml.apache.org
> Subject: RE: File upload in cocoon:
> org.apache.cocoon.components.request.multipart.FilePart is missing.
> 
> 
> Yes, this was moved and slightly refactored and even the wiki hasn't
> totally caught up yet.  Even though you want to do this in an action,
> you should find what you need here:
> http://wiki.cocoondev.org/Wiki.jsp?page=FileUploadsWithFlow
> 
> Notice the new package is org.apache.cocoon.servlet.multipart - some
> of the class names have changed, but most of the concepts are the
> same.  The bottom section should give you what you need to fix the
> action for uploads - if not, write back.
> 
> By the way, the jars.html you refer to is for 2.0.x (as is 
> all of the live
> site for now).  The maybeupload jar is no longer an option (nor was it
> useful in the recent past).
> 
> HTH,
> Geoff Howard
> 
> > -----Original Message-----
> > From: Kogan Irina [mailto:Irina.Kogan@mchp.siemens.de]
> > Sent: Thursday, May 15, 2003 10:58 AM
> > To: cocoon-users@xml.apache.org
> > Subject: File upload in cocoon:
> > org.apache.cocoon.components.request.multipart.FilePart is missing.
> >
> >
> > Hello all,
> >
> > I am trying to upload a file using Cocoon, as
> > 
http://wiki.cocoondev.org/Wiki.jsp?page=FileUploadWithAction suggests.
> However, for some reason
> org.apache.cocoon.components.request.multipart.FilePart (to be imported to
> my UploadTest) is not in any of the jars files in the
> \jakarta-tomcat-4.1.24-LE-jdk14\webapps\cocoon\WEB-INF\lib directory.  (I
> would assume it should be in cocoon-2.1-M1.jar, since
> org.apache.cocoon.components is there, but it is not there.)  Does anybody
> know where I can get this package?
>
> In the http://xml.apache.org/cocoon/installing/jars.html, they are talking
> about the optional jar file for servlet upload support.  Do I
> need that or a
> special build target (a parameter for "built.bat" for ant) to get upload
> support?
>
> Does anybody know how to insert upload into the 2.1 build process or with
> what class the old one has been replaced?
>
> Thanks a lot in advance,
>
> Irina.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>
>


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

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


Newbie: Escaping markup in XSP

Posted by Joe Williams <jo...@mindspring.com>.
I'm working through the example apps in Lajos Moczar and Jeremy Aston's
book. The "Trouble Tickets" app asks users to log in, the provides no way to
go straight to view their tickets from the authentication page.

What's the recommended way to solve this? Links in the content below the
code? Or is there a way to escape a hyperlink in the "msg" output?

The java from the top of the XSP follows

Thanks.

Joe

=======================
if (user.equals("MegaBancShares") &amp;&amp; pwd.equals("secret")) {

msg = "User '" + user + "' has been authenticated" +

" - you can now proceed to the support page.";

<xsp-session:set-attribute
name="user"><xsp:expr>user</xsp:expr></xsp-session:set-attribute>;

} else if (user.equals("Jollyville National Bank") &amp;&amp;
pwd.equals("secret")) {

msg = "User '" + user + "' has been authenticated" +

" - you can now proceed to the support page.";

<xsp-session:set-attribute
name="user"><xsp:expr>user</xsp:expr></xsp-session:set-attribute>;

} else {

msg = "Login failed";

}



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


RE: File upload in cocoon: org.apache.cocoon.components.request.m ultipart.FilePart is missing.

Posted by Geoff Howard <co...@leverageweb.com>.
Yes, I know what's wrong:
1) Your action returns null under every condition.  The action contract 
requires that successful actions return a Map (even if empty) and 
unsuccessful actions return null.
2) Your pipeline only contains a generator in the condition that the action 
succeeds (which because of the problem above it never will).

You need to fix both of these.

Geoff

At 11:58 AM 5/16/2003, you wrote:
>Thank you very much for your answer!
>
>I have written the file UploadTest.jar (for now doing pretty much nothing)
>and put the class UploadTest into the package upload.test:
>
>package upload.test;

...

>public class UploadTest
>   extends AbstractLogEnabled
>   implements Action, ThreadSafe
>{
>     public Map act(Redirector redirector, SourceResolver resolver,
>                    Map objectModel, String source, Parameters par)
>         throws Exception
>     {

...

>         return null;
>     }
>}

...

><map:match pattern="*.html">
>     <map:read src="{1}.html"/>
></map:match>
>
><map:match pattern="file">
>      <map:act type="upload" src="optional src">
>            <map:generate type="html" src="success.html"/>
>      </map:act>
>      <map:serialize/>
></map:match>
>
>When I go to the page http://localhost:8080/cocoon/samples/test/upload.html,
>I get the following error message:
>
>Internal Server Error


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