struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Bohnenberger <bill98...@gmail.com>
Subject Re: problem uploading a text file
Date Fri, 04 Sep 2009 21:50:47 GMT
Well, I am the one who is confused, for sure. I restarted eclipse and now I
can upload *.txt files just fine with my original xml:

   <action name="BulkUpload_*" class="com.rp.db.actions.BulkUpload"
method="{1}">
        <result name="input">bulkUpload.jsp</result>
        <result name="done" type="redirect">Menu_init</result>
        <result name="login" type="redirect">Login_init</result>
    </action>

Arrg, this is not the first time Eclipse has refused to work properly in
"hosted" mode until I restarted it. But this time I totally forgot to try
that tactic :(  Sorry for the bother!

Bill

On Fri, Sep 4, 2009 at 1:41 PM, Chris Pratt <thechrispratt@gmail.com> wrote:

> I guess I don't understand why the interceptor would care what the content
> of the file is.  It's only job is to inject the parameters into the action.
>  (*Chris*)
>
> On Fri, Sep 4, 2009 at 1:24 PM, Bill Bohnenberger <bill98122@gmail.com
> >wrote:
>
> > Thanks, Chris, but I don't think that's the problem. I have another jsp
> > page
> > and associated action that uploads .jpg and .gif images ok with the same
> > variables...the only difference is that I am tying to get the fileUpload
> > interceptor to accept a *.txt file. (Sorry, I should've mentioned all
> this
> > in my original post)
> >
> > Bill
> >
> > On Fri, Sep 4, 2009 at 12:36 PM, Chris Pratt <thechrispratt@gmail.com
> > >wrote:
> >
> > > I believe the documentation is incorrect on the web.  The setUpload
> > doesn't
> > > take a File object, it takes a String that is the fully qualified path
> to
> > > the temporary file created by the internal upload support of struts.
>  So
> > > what you actually need is:
> > >
> > >   public void setUpload(String upload)
> > >   {
> > >       this.upload = new File(upload);
> > >   }
> > >
> > > (*Chris*)
> > >
> > > On Fri, Sep 4, 2009 at 11:40 AM, Bill Bohnenberger <
> bill98122@gmail.com
> > > >wrote:
> > >
> > > > Ok, I'm sure I must be doing something dumb here, but I can't seem to
> > > find
> > > > it. I'm have a problem uploading a simple text file... when I try to
> a
> > > file
> > > > named "test.txt", I get an action error message "File upload error:
> > > invalid
> > > > data." and all my file variables (see below) are null when the action
> > > > method
> > > > gets called.
> > > >
> > > > Here's my setup:
> > > >
> > > > Config:
> > > >
> > > >    <action name="BulkUpload_*" class="com.rp.db.actions.BulkUpload"
> > > > method="{1}">
> > > >        <interceptor-ref name="basicStack"/>
> > > >        <interceptor-ref name="fileUpload">
> > > >            <param name="maximumSize">8192000</param>
> > > >            <param
> > > > name="allowedTypes">image/jpeg,image/gif,text/plain</param>
> > > >        </interceptor-ref>
> > > >        <interceptor-ref name="validation"/>
> > > >        <interceptor-ref name="workflow"/>
> > > >
> > > >        <result name="input">bulkUpload.jsp</result>
> > > >        <result name="done" type="redirect">Menu_init</result>
> > > >        <result name="login" type="redirect">Login_init</result>
> > > >    </action>
> > > >
> > > > Relevant jsp code:
> > > >
> > > > <s:form action="BulkUpload_doCommand" method="post"
> > > > enctype="multipart/form-data">
> > > >    <s:file label="Bulk File" name="upload" size="45"/>
> > > >    <s:submit name="command" value="Upload File"/>
> > > >    <s:submit name="command" value="Cancel"/>
> > > > </s:form>
> > > >
> > > > Action excerpts:
> > > > ...
> > > >    private String uploadContentType;
> > > >    private String uploadFileName;
> > > >    private File upload;
> > > > ...
> > > >    public void setUpload(File upload)
> > > >    {
> > > >        this.upload = upload;
> > > >    }
> > > >    public void setUploadFileName(String uploadFileName)
> > > >    {
> > > >        this.uploadFileName = uploadFileName;
> > > >    }
> > > >    public void setUploadContentType(String uploadContentType)
> > > >    {
> > > >        this.uploadContentType = uploadContentType;
> > > >    }
> > > >
> > > > As I mentioned above, when I use this form to upload a text file
> named
> > > > "test.txt" I get the action error message "File upload error: invalid
> > > > data."
> > > > and all my "upload..." variables are null.
> > > >
> > > > Thanks,
> > > > Bill
> > > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message