I was trying stuff out and i hve got it working perfectly.

Only thing is my that my execute is returning a SUCCESS when
everything is done.  However I do not have any <result> in my
struts.xml for this action. since the user shouldnt be moved to
another page.

Now I am able to see open /save dialog box as well and excel opens
fine too but in my logs i ssee the following exception..


StandardWrapperValve[default]: Servlet.service() for servlet default
threw exception
java.lang.IllegalStateException
        at 
org.apache.coyote.tomcat5.CoyoteResponseFacade.sendError(CoyoteResponseFacade.java:390)
        at 
org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:127)
        at 
org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:178)
        at 
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348)
        at 
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253)
        at 
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
        at 
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)


..what should my execute method be returning?



On 2/7/08, Mike Jennings <[EMAIL PROTECTED]> wrote:
You can do this by creating a custom result type.
>
> A example of a custom result type for streaming images from a action to
> a img tag is here.
>
> http://struts.apache.org/2.x/docs/how-can-we-display-dynamic-or-static-images-that-can-be-provided-as-an-array-of-bytes.html
>
> You can use this as a example, but will probably have to have a modify
> it slightly so that your action will have a getter and setter to pass a
> output stream to the result type.  In the result type you can write the
>   output stream to the response output stream.
>
> Mike Jennings
>
> bhaarat Sharma wrote:
> > Hello
> >
> > I have a S2 action working perfectly fine.  But on one page of my web
> > App I would like the user to be able to download report in Excel.  We
> > have this functionality in other pages as well but they arent using S2
> > and are doing this via a custom servlet which has doGet doPost and
> > processRequest methods.
> >
> > Inside the processRequest..they do bunch of stuff to get the excel
> > read and in the end do this:
> >
> >      ServletOutputStream stream = null;
> >      String fileName = \\\"something\\\";
> >
> >
> >          response.addHeader(\\\"Content-Disposition\\\", \\\"attachment;
> > filename=\\\" + fileName);
> >          response.setContentType(\\\"application/vnd.ms-excel\\\");
> >          stream = response.getOutputStream();
> >          wb.write(stream);
> >
> > this is a void method.
> >
> > My question is, since in my case I already have a S2 action..I dont
> > want to make a new servlet to do this.
> >
> > How can i do the same in my execute method for S2?? what should the
> > execute method return? because when user clicks get Excel link..the
> > page stays the same but just the user is presented with open/save
> > dialog.
> >
> > Woudl appreciate any help.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> > --------------------------------
> > Spam/Virus scanning by CanIt Pro
> >
> > For more information see
> > http://www.kgbinternet.com/SpamFilter.htm
> >
> > To control your spam filter, log in at
> > http://filter.kgbinternet.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to