Creating File Upload using servlets: need help

Discussions

Web tier: servlets, JSP, Web frameworks: Creating File Upload using servlets: need help

  1. Creating File Upload using servlets: need help (1 messages)

    Hi,

    i have been assigned a task to create a simple upload file application using struts in servlets. I have gone thru the file-upload.war in the struts 1.1 webapps folder and made some changes to it.. but i could not save the file i uploaded to disk even though my applications already stated that my upload was successul...

    can anyone help me out here... i'm a newbie in training...:D

    regards
    Jimmy
  2. Hi,
    When uploading a file, the struts keep sthe upoaded bytes in memory. If the ulpoad content size exceeds a threshold, only then struts saves the upload contnet to the disk. This threshold value is specified by the 'maxFileSize' servlet init parameter of the struts action servlet. However, you should work with the input stream of the FormFile and save the upload content wherever you wan: databse BLOB, file syste, etc. Also don't forget to call the 'destroy()' on your form file aftre your done with the stream.
    Best regardds, Mircea