We help IT Professionals succeed at work.
Get Started

how to make streamInfo compatable with mapping.getInputForwar()

Last Modified: 2008-09-11

I am downloading  the file using Structs DownlaodAction,
so I am overriding the method getStreamInfo() in my ActionClass, it return type is StreamInfo,
 how to type cast ActionMapping.getInputForward() so it's return type should be compatalbe to  StreamInfo...
as I am using ActionMapping.getInputForward()  inside the the method getStreamInfo(),  as my return type.....

Here is my Action class..
public class  MEDloadAction extends BaseAction {

        protected StreamInfo getStreamInfo(ActionMapping mapping,
                                       ActionForm form,
                                       HttpServletRequest request,
                                       HttpServletResponse response) throws Exception {        
        ActionMessages ErrorMessages = new ActionMessages();
        String contentType = null;
        String  filePath = null;
        String  fileName = null;
        String  fileExt = null;
        String  file = null;
        try {
             MDloadForm  mEForm= (MDloadForm)form;
             contentType= Constants.APPLICATION_CONTENT_TYPE; //octet-stream
             int measureID = mEForm.getMeasure();
             MessageResources messageResources = getResources(request);              
             filePath = messageResources.getMessage("measurePath");        
             fileName = messageResources.getMessage(measureID+Constants.BLANK_STRING);
             fileExt = messageResources.getMessage("measureExt");
             file = filePath + fileName + fileExt;
             response.setHeader("CONTENT-DISPOSITION", "attachment; filename=\"" + fileName + fileExt + "\"");
             return new ResourceStreamInfo(contentType, servlet.getServletContext(), file);
        } catch(Exception e) {            
                         ErrorMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.Exception"));            
             saveAppErrors(request, ErrorMessages);
             return (StreamInfo)mapping.getInputForward();

Watch Question
This problem has been solved!
Unlock 1 Answer and 11 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE