Eddie, you are not answering my question at all. My question is how to use
<html:file> tag and retrieve the content of file.


---------------------------------------------------------------------------
Henry Lu
MCIT                                            phone: (734) 936-2063
University of Michigan Medical Center           fax:   (734) 763-4372

On Thu, 21 Feb 2002, Eddie Bush wrote:

> The validate function can be implemented to validate your form input.  If
> you find erros, you can put those errors into an ActionErrors object and
> then return them.  The 'best practice' approach would probably be to have
> your validation encapsulated in a 'utility bean' that you could instantiate
> to make calls against (that's how I am doing mine anyway).  However, for a
> small project you could easily include all of you login right in validate.
> There is a good example of doing this in the struts documentation, and I
> believe the users guide covers the topic quite well too.  If you haven't
> already looked them over, you really should.
>
> How to best use the validation mechanisms provided by struts is quite a
> debated issue =)
>
> No matter where/how you implement your logic to validate your form, you'll
> want to create an ActionErrors instance and add ActionError instances to it,
> and finally return the ActionErrors object.  Very simply:
>
> ActionErrors actionErrors = new ActionErrors();
>
> ... then, assuming they don't specify a file - and assuming it is a required
> field.
>
> actionErrors.add("File", new ActionError("error.file.required"));
>
> and then at the end of your perform, don't forget to:
>
> return actionErrors;
>
> The text passed to the ActionError constructor ("error.file.required") needs
> to be specified in your application resources file.
>
> HTH,
>
> Eddie
>
> ----- Original Message -----
> From: "Henry Lu" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> Sent: Thursday, February 21, 2002 12:58 PM
> Subject: Re: <html:file> tag
>
>
> > Thanks for your info! But I need a little bit more details:
> >
> > //int my FileForm.java file
> > /////////////////////////////////////////////////////
> > public class FileForm extends ActionForm
> > {
> >    private String theFile;
> >
> >    public FileForm() {}
> >
> >    public void setTheFile(String file)
> >    {
> >       this.theFile = file;
> >    }
> >
> >    public String getTheFile()
> >    {
> >       return this.theFile;
> >    }
> >
> >    ...
> >
> >    public ActionErrors validate(...)
> >    {
> >       ////////////////////////////////////
> >       // what should i do here?
> >    }
> > }
> >
> > //////////////////////////////////////////////////////
> > //int the jsp page:
> > ////////////////////////////////////////////////////////
> > <html:file property="theFile" accept="text" />
> >
> > Could you tell me what exactly to do and where to add code?
> >
> > Thank you very much!
> >
> >
> > --------------------------------------------------------------------------
> -
> > Henry Lu
> > MCIT                                            phone: (734) 936-2063
> > University of Michigan Medical Center           fax:   (734) 763-4372
> >
> > On Thu, 21 Feb 2002, SUPRIYA MISRA wrote:
> >
> > > In your validation function first store it.
> > > Stringbuffer filecontent= file content.
> > > request.setAttribute("file",filecontent);
> > > On Jsp use equal tag to see if you have the content--take it else ask
> for a
> > > new one.
> > >
> > >
> > > >From: Henry Lu <[EMAIL PROTECTED]>
> > > >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> > > >To: struts users <[EMAIL PROTECTED]>
> > > >Subject: <html:file> tag
> > > >Date: Thu, 21 Feb 2002 10:48:05 -0500 (EST)
> > > >
> > > >How do i retrieve the content of file in the formAction program? The
> only
> > > >thing I get from the tag is the file name (exa: 1.txt). How do I get
> the
> > > >content of the file?
> > > >
> > > >
> > >
> >---------------------------------------------------------------------------
> > > >Henry Lu
> > > >MCIT                                            phone: (734) 936-2063
> > > >University of Michigan Medical Center           fax:   (734) 763-4372
> > > >
> > > >
> > > >--
> > > >To unsubscribe, e-mail:
> > > ><mailto:[EMAIL PROTECTED]>
> > > >For additional commands, e-mail:
> > > ><mailto:[EMAIL PROTECTED]>
> > > >
> > >
> > >
> > >
> > >
> > > _________________________________________________________________
> > > Chat with friends online, try MSN Messenger: http://messenger.msn.com
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to