[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 567
  • Last Modified:

struts action - forward to file dialog

I am wanting to open an excell file from the Struts action class

My code in the Sruts action class looks as follows:
ActionForward af = new ActionForward("/userdata/test.xls");

It opens a dialog box.

My problem is the name of the file(instead of test.xls) is the name of the .do function called from my JSP to run this action.
0
javaone
Asked:
javaone
  • 2
  • 2
2 Solutions
 
TimYatesCommented:
in your action, can you do:

  response.setContentType( "application/xls" ) ;

then write the excel file to the stream you get from

  response.getOutputStream() ;

?
0
 
Rick_TownsendCommented:
you could do a redirect

response.sendRedirect("userdata/test.xls");

or just have whatever link you're using point directly to the file.
0
 
Rick_TownsendCommented:
Say, the date on this question is more than two weeks old.  Should it be closed due to author inactivity?
0
 
TimYatesCommented:
> or just have whatever link you're using point directly to the file.

You will have to check that you have the correct mime-type in server.xml for this to work, but it should work too :-)

>  Say, the date on this question is more than two weeks old.  Should it be closed due to author inactivity?

Probably ;-)  Hehehe, I imagine there will be a flurry of cleanup activity sometime this month :-D
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now