Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Return File Content from EJB

 
Chetan Chandarana
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

In my application, i have a servlet that call EJB.
EJB creates a file and now servlet has to download this to user
Both EJB and Servlets are on different servers

I have one option that EJB would return the file name to be downloaded
and servlet will do FTP to download file(Considering i do all setting for servlet to download file from the server where EJB are deployed)

Do you have any better solution for this problem?
Would highly appreciate if you could share some ideas

Cheers
Chetan
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are remembering that you should not perform any file system IO from an EJB right?
 
Chetan Chandarana
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, i do remember ... thats why i want to know what is the best way to achieve this?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well the only safe way to access file systems resources from an EJB is via a JCA adapter. You'll need to write/find one of them.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you can create the File from your Servlet through a POJO class, and maybe use the FileUpload apis that come with Apache Commons.

Just an idea.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic