Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 582
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

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