At 10:06 AM +0800 2002/06/18, Daniel J. D'Cotta wrote: >So can someone answer my 3 questions (without suggesting Expresso)? > >1. First, I have a concern for memory usage while uploading a huge (100+Mb) >file. How does Struts handle uploading the file? Or is this purely a Web >Server issue. > >Also, I am using the org.apache.struts.upload.FormFile class to read it. >Does it matter if I use getInputStream() read batch-by-batch or >getFileData()?
Note that FormFile is an interface, not a class, so you could conceivably write a new implementation to address any performance issues. Most folks just use "org.apache.struts.upload.DiskFile", which is the default. To customize, you would actually implement both MultipartRequestHandler and FormFile differently as necessary, because you plug these in by specifying a "multipartClass" property of your controller (in web.xml for Struts 1.0 and in the <controller> element of your struts-config in 1.1). The multipart handler is what creates objects of type "FormFile" to set those properties on your FormBean. The default implementation writes the file to disk, so memory shouldn't be a problem. I've found the form upload stuff to be extremely easy to implement, although I did it more by guesswork than from documentation. >2. Next, when I pre-set the value, it does not show in the input field. > > <input type="file" id="file" name="file" size="50" value="temp.txt"/> > >I read somewhere that that is a html thing. Any way to get around it? Although "value" seems to be in the spec, I don't know of any browsers that pay any attention to values you put there. >3. Finally, How do you let users download a file with Struts? The file >cannot be outside WEB-INF. > >(Could not find any documentation on this part, if you ask me to RTFM, >please direct me to which part of the manual). You'd need to write directly to the HttpServletResponse object and return a null ActionMapping from the perform/execute method of your Action. You're responsible for setting all the headers (content type, etc). But this isn't hard to do -- it's just not something that Struts helps you do. Hope that helps, Joe -- -- * Joe Germuska { [EMAIL PROTECTED] } "It's pitiful, sometimes, if they've got it bad. Their eyes get glazed, they go white, their hands tremble.... As I watch them I often feel that a dope peddler is a gentleman compared with the man who sells records." --Sam Goody, 1956 tune in posse radio: <http://www.live365.com/stations/289268> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>