This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes multipart/form-data and request.getAttribute. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "multipart/form-data and request.getAttribute." Watch "multipart/form-data and request.getAttribute." New topic
Author

multipart/form-data and request.getAttribute.

Sam Mites
Greenhorn

Joined: Nov 27, 2005
Posts: 15
Hi,
When ever i upload a file, i use encryption type as multipart/form-data in the form. But that way the form bean isn't get populated and the request.getParameter do not work. But by using request.getAttribute i am able to get the values in form. Why is this so?? (Isn't struts have anything in place to populate form beans through reflection when encryption type is multipart/form-data?)
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I've written several upload JSPs using Struts and they populate the form bean just fine. The trick is that you have to define the file to be uploaded as type org.apache.struts.upload.FormFile and use the <html:file> tag in the jsp.

There is an example of a file upload in the struts-examples.war file that comes with the download. I'd suggest carefully studying their example to see how it's done.
[ February 03, 2006: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
 
Don't get me started about those stupid light bulbs.
 
subject: multipart/form-data and request.getAttribute.
 
Similar Threads
form to upload files
how to get radio button value
POST data with a file upload
Error While Uploading
File uploading and data collection problem