• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Struts 2 : file upload

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

i am using tomcat server and strut 2 application

my problem is

when i am uploading the file using



then in action class

i am having getters and setters

like this



i am getting the values of all above

like file object with path like c://tomcat//work//catelina//....//xyz.tmp

and content = text / ...

and fileName = sss.txt (actual file name)

now problem is

I need to pass this file object to next action that is

From this action i have to go to other jsp ( collect some text )and then i have to go to the next action and submit these values to db.

1. so i have tried to save the same path c://tomcat//work//catelina//....//xyz.tmpand tried to send to other action & create new file object , but observed that when the first action get completes the "c://tomcat//work//catelina//....//xyz.tmp" gets deleted


CAN any one tell me how to handle this....

1. how can i get actual path of the file (c://xfolder//yfolder//sss.txt)
2. or is there any way to save the .tmp file till i complete my operations in action that is inserting values in DB.
3. or any way i can pass the file object created in one action to other action through JSP.
4. if i have to save this file into new location then where we have to save (in the tomcat...).

or any better solution please tell me

Thanks friends,

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The upload interceptor deletes the file after the action is completed. If you need it copied somewhere else, just copy it.

You could use a dynamic result (see here and here for details) to pass the filename to another action, but that shouldn't be necessary--whatever logic is handling the file should be abstracted out of individual actions into a service-like object that can be used anywhere.
 
kajal mukergi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks David,

The links are very informative.

Thanks
Kajal
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic