?
Solved

Struts FormFile

Posted on 2005-03-20
10
Medium Priority
?
693 Views
Last Modified: 2012-05-05
I have a web application that is written in struts. In the application a user can enter info and upload a file.
All of this is then stored in a database.  I have retrieved the uploaded file from the database and have it in
byte[] array.

How do I put this back into the struts FormFile????


Anyone?

Thanks
0
Comment
Question by:u9707118
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13589471
Somehting like this:

// .. get data into an array named "byteArray"
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(byteArray));
 
// .. get FormFile object
FormFile formFile= (FormFile) ois.readObject();
 
// close the input stream
ois.close();
0
 

Author Comment

by:u9707118
ID: 13647250
didn't work, I'm afraid :(
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13647528
what was the error/exception?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 29

Expert Comment

by:bloodredsun
ID: 14232603
I think so, I think I misunderstood the question. I thought he wanted to deserialize the actionform when he just wanted to know how to put a byte array back in the form....
0
 

Author Comment

by:u9707118
ID: 14234519
Sorry, I forgot about this question....

I managed to get around the problem by storing the file in the session and not in the action form.
I did try your code at the time, I remember that the code did execute i.e. it seemingly read the file bytes
into the FormFile without throwing any exceptions, but when I tried to retrieve the file an exception occurred.

I can't remember what exactly the error said...something like corrupt data.
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 14236149
not a problem u907118, you get your points back for answering it yourself :-)
0
 
LVL 20

Expert Comment

by:Venabili
ID: 14238085
Changed recommendation: PAQ- refund
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 14238602
>> Changed recommendation: PAQ- refund
Agreed
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 14255352
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question