You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by sv...@bnymellon.com on 2012/04/10 22:29:37 UTC

struts2 problem when file download dialog is closed

Hi,

I've created a struts2 application that creates text file and displays the 
file download dialog for the user to open or save it.
It works fine if the user opens or saves it, but if the user closes the 
file download dialog the program logs the following error:

Servlet failed with Exception
java.lang.IllegalStateException: Response already committed
        at 
weblogic.servlet.internal.ServletResponseImpl.objectIfCommitted(Servl
etResponseImpl.java:1422)
        at 
weblogic.servlet.internal.ServletResponseImpl.sendError(ServletRespon
seImpl.java:580)
        at 
org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:77
1)
        at 
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.jav
a:506)
        at 
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatc
her.java:395)
        Truncated. see log file for complete stacktrace
>

My struts.xml file code is as follows:

<action name="AdmExport" class="ConfigAction" method="export">
            <result name="success" type="stream"> 
            <param name="contentType">application/octet-stream</param>
                <param name="inputName">inputStream</param>
                <param 
name="contentDisposition">attachment;filename="tempExport.txt"</param>
                <param name="bufferSize">1024</param> 
           </result>
        </action>
 
My action class code is as follows:

import org.apache.struts2.interceptor.SessionAware;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;


public class ConfigAction extends ActionSupport  implements SessionAware
{

public void setInputStream(InputStream inputStream) {
                this.inputStream = inputStream;
        }
public InputStream getInputStream() {
                return inputStream;
        }

public String export() throws Exception {
 
                try
                { 
                  // code to create tempExport.txt file 
 
                        File exportFile = new File("./tempExport.txt");
                        setInputStream(new FileInputStream(exportFile));
                        exportFile.delete();
                }
                catch (Exception ex)
                { 
                        ex.printStackTrace();
                }
 
                return SUCCESS;
        } 
}

Any ideas as how to fix the issue will be greatly appreciated.

Thanks,

Svetlana Roslyakova ·  The Bank of New York Mellon 
Regulatory Systems · Tel 212.815.8043 · svetlana.roslyakova@bnymellon.com

The information contained in this e-mail, and any attachment, is confidential and is intended solely for the use of the intended recipient. Access, copying or re-use of the e-mail or any attachment, or any information contained therein, by any other person is not authorized. If you are not the intended recipient please return the e-mail to the sender and delete it from your computer. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses. 

Please refer to http://disclaimer.bnymellon.com/eu.htm for certain disclosures relating to European legal entities.

Re: struts2 problem when file download dialog is closed

Posted by Muneer Malik <tu...@gmail.com>.
when the dialog closes, are you still calling the action ? 



Best,
Muneer Malik

On Apr 10, 2012, at 3:29 PM, svetlana.roslyakova@bnymellon.com wrote:

> Hi,
> 
> I've created a struts2 application that creates text file and displays the 
> file download dialog for the user to open or save it.
> It works fine if the user opens or saves it, but if the user closes the 
> file download dialog the program logs the following error:
> 
> Servlet failed with Exception
> java.lang.IllegalStateException: Response already committed
>        at 
> weblogic.servlet.internal.ServletResponseImpl.objectIfCommitted(Servl
> etResponseImpl.java:1422)
>        at 
> weblogic.servlet.internal.ServletResponseImpl.sendError(ServletRespon
> seImpl.java:580)
>        at 
> org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:77
> 1)
>        at 
> org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.jav
> a:506)
>        at 
> org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatc
> her.java:395)
>        Truncated. see log file for complete stacktrace
>> 
> 
> My struts.xml file code is as follows:
> 
> <action name="AdmExport" class="ConfigAction" method="export">
>            <result name="success" type="stream"> 
>            <param name="contentType">application/octet-stream</param>
>                <param name="inputName">inputStream</param>
>                <param 
> name="contentDisposition">attachment;filename="tempExport.txt"</param>
>                <param name="bufferSize">1024</param> 
>           </result>
>        </action>
> 
> My action class code is as follows:
> 
> import org.apache.struts2.interceptor.SessionAware;
> import com.opensymphony.xwork2.ActionContext;
> import com.opensymphony.xwork2.ActionSupport;
> 
> 
> public class ConfigAction extends ActionSupport  implements SessionAware
> {
> 
> public void setInputStream(InputStream inputStream) {
>                this.inputStream = inputStream;
>        }
> public InputStream getInputStream() {
>                return inputStream;
>        }
> 
> public String export() throws Exception {
> 
>                try
>                { 
>                  // code to create tempExport.txt file 
> 
>                        File exportFile = new File("./tempExport.txt");
>                        setInputStream(new FileInputStream(exportFile));
>                        exportFile.delete();
>                }
>                catch (Exception ex)
>                { 
>                        ex.printStackTrace();
>                }
> 
>                return SUCCESS;
>        } 
> }
> 
> Any ideas as how to fix the issue will be greatly appreciated.
> 
> Thanks,
> 
> Svetlana Roslyakova ·  The Bank of New York Mellon 
> Regulatory Systems · Tel 212.815.8043 · svetlana.roslyakova@bnymellon.com
> 
> The information contained in this e-mail, and any attachment, is confidential and is intended solely for the use of the intended recipient. Access, copying or re-use of the e-mail or any attachment, or any information contained therein, by any other person is not authorized. If you are not the intended recipient please return the e-mail to the sender and delete it from your computer. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses. 
> 
> Please refer to http://disclaimer.bnymellon.com/eu.htm for certain disclosures relating to European legal entities.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: struts2 problem when file download dialog is closed

Posted by sv...@bnymellon.com.
Adam,

The control is out of the action class and if the user will open or save 
the file, there is no problem and the control goes to the JSP page.
For some reason once the error occurs if the user clicks another button 
that makes AJAX call to server, the call does not go through but instead 
returns cashed results from the previous AJAX call.

Thanks,

Lana.






From:   adam pinder <ap...@hotmail.co.uk>
To:     <us...@struts.apache.org>
Date:   04/11/2012 01:46 PM
Subject:        RE: struts2 problem when file download dialog is closed





is the user "cancelling" still sending a request to the server and hence 
you are trying to return an error - if so i'd assume the http connection 
has been terminated and therefore you can't send an http response back.
if its just logged but doesn't stop user experience then leave it.


> To: user@struts.apache.org
> Subject: Re: struts2 problem when file download dialog is closed
> From: svetlana.roslyakova@bnymellon.com
> Date: Wed, 11 Apr 2012 09:51:39 -0400
> 
> Venkata,
> 
> I use Struts2 2.2.1.1 version.
> I've changed the filter to StrutsPrepareAndExecute Filter.
> 
> The same error:
> 
>  Servlet failed with Exception
> java.lang.IllegalStateException: Response already committed
>         at 
> weblogic.servlet.internal.ServletResponseImpl.objectIfCommitted(Servl
> etResponseImpl.java:1422)
>         at 
> weblogic.servlet.internal.ServletResponseImpl.sendError(ServletRespon
> seImpl.java:580)
>         at 
> org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:77
> 1)
>         at 
> org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.jav
> a:506)
>         at 
> org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(Exec
> uteOperations.java:77)
>         Truncated. see log file for complete stacktrace
> >
> 
> Muneer,
> 
> When the user closes dialog the control goes to jsp page, but the 
behavior 
> is strange as when I try subsequently to do AJAX call, it does not go to 

> the server, but instead uses the cashed response.
> 
> Thanks,
> 
> Lana.
> 
> 
> 
> 
> 
> 
> From:   vEnkaTa mohAna rAo SriperumbUdUru <mo...@gmail.com>
> To:     Struts Users Mailing List <us...@struts.apache.org>
> Date:   04/10/2012 09:19 PM
> Subject:        Re: struts2 problem when file download dialog is closed
> 
> 
> 
> You are using older version Struts2.x and change filter to
> StrutsPrepareAndExecute Filter.
> 
> 
> On Wed, Apr 11, 2012 at 1:59 AM, <sv...@bnymellon.com> 
> wrote:
> 
> > Hi,
> >
> > I've created a struts2 application that creates text file and displays 

> the
> > file download dialog for the user to open or save it.
> > It works fine if the user opens or saves it, but if the user closes 
the
> > file download dialog the program logs the following error:
> >
> > Servlet failed with Exception
> > java.lang.IllegalStateException: Response already committed
> >        at
> > weblogic.servlet.internal.ServletResponseImpl.objectIfCommitted(Servl
> > etResponseImpl.java:1422)
> >        at
> > weblogic.servlet.internal.ServletResponseImpl.sendError(ServletRespon
> > seImpl.java:580)
> >        at
> > org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:77
> > 1)
> >        at
> > org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.jav
> > a:506)
> >        at
> > org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatc
> > her.java:395)
> >        Truncated. see log file for complete stacktrace
> > >
> >
> > My struts.xml file code is as follows:
> >
> > <action name="AdmExport" class="ConfigAction" method="export">
> >            <result name="success" type="stream">
> >            <param name="contentType">application/octet-stream</param>
> >                <param name="inputName">inputStream</param>
> >                <param
> > name="contentDisposition">attachment;filename="tempExport.txt"</param>
> >                <param name="bufferSize">1024</param>
> >           </result>
> >        </action>
> >
> > My action class code is as follows:
> >
> > import org.apache.struts2.interceptor.SessionAware;
> > import com.opensymphony.xwork2.ActionContext;
> > import com.opensymphony.xwork2.ActionSupport;
> >
> >
> > public class ConfigAction extends ActionSupport  implements 
SessionAware
> > {
> >
> > public void setInputStream(InputStream inputStream) {
> >                this.inputStream = inputStream;
> >        }
> > public InputStream getInputStream() {
> >                return inputStream;
> >        }
> >
> > public String export() throws Exception {
> >
> >                try
> >                {
> >                  // code to create tempExport.txt file
> >
> >                        File exportFile = new File("./tempExport.txt");
> >                        setInputStream(new 
FileInputStream(exportFile));
> >                        exportFile.delete();
> >                }
> >                catch (Exception ex)
> >                {
> >                        ex.printStackTrace();
> >                }
> >
> >                return SUCCESS;
> >        }
> > }
> >
> > Any ideas as how to fix the issue will be greatly appreciated.
> >
> > Thanks,
> >
> > Svetlana Roslyakova ·  The Bank of New York Mellon
> > Regulatory Systems · Tel 212.815.8043 · 
> svetlana.roslyakova@bnymellon.com
> >
> > The information contained in this e-mail, and any attachment, is
> > confidential and is intended solely for the use of the intended 
> recipient.
> > Access, copying or re-use of the e-mail or any attachment, or any
> > information contained therein, by any other person is not authorized. 
If
> > you are not the intended recipient please return the e-mail to the 
> sender
> > and delete it from your computer. Although we attempt to sweep e-mail 
> and
> > attachments for viruses, we do not guarantee that either are 
virus-free 
> and
> > accept no liability for any damage sustained as a result of viruses.
> >
> > Please refer to http://disclaimer.bnymellon.com/eu.htm for certain
> > disclosures relating to European legal entities.
> 
> 
> The information contained in this e-mail, and any attachment, is 
confidential and is intended solely for the use of the intended recipient. 
Access, copying or re-use of the e-mail or any attachment, or any 
information contained therein, by any other person is not authorized. If 
you are not the intended recipient please return the e-mail to the sender 
and delete it from your computer. Although we attempt to sweep e-mail and 
attachments for viruses, we do not guarantee that either are virus-free 
and accept no liability for any damage sustained as a result of viruses. 
> 
> Please refer to http://disclaimer.bnymellon.com/eu.htm for certain 
disclosures relating to European legal entities.
  

The information contained in this e-mail, and any attachment, is confidential and is intended solely for the use of the intended recipient. Access, copying or re-use of the e-mail or any attachment, or any information contained therein, by any other person is not authorized. If you are not the intended recipient please return the e-mail to the sender and delete it from your computer. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses. 

Please refer to http://disclaimer.bnymellon.com/eu.htm for certain disclosures relating to European legal entities.

RE: struts2 problem when file download dialog is closed

Posted by adam pinder <ap...@hotmail.co.uk>.

is the user "cancelling" still sending a request to the server and hence you are trying to return an error - if so i'd assume the http connection has been terminated and therefore you can't send an http response back.
if its just logged but doesn't stop user experience then leave it.


> To: user@struts.apache.org
> Subject: Re: struts2 problem when file download dialog is closed
> From: svetlana.roslyakova@bnymellon.com
> Date: Wed, 11 Apr 2012 09:51:39 -0400
> 
> Venkata,
> 
> I use Struts2 2.2.1.1 version.
> I've changed the filter to StrutsPrepareAndExecute Filter.
> 
> The same error:
> 
>  Servlet failed with Exception
> java.lang.IllegalStateException: Response already committed
>         at 
> weblogic.servlet.internal.ServletResponseImpl.objectIfCommitted(Servl
> etResponseImpl.java:1422)
>         at 
> weblogic.servlet.internal.ServletResponseImpl.sendError(ServletRespon
> seImpl.java:580)
>         at 
> org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:77
> 1)
>         at 
> org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.jav
> a:506)
>         at 
> org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(Exec
> uteOperations.java:77)
>         Truncated. see log file for complete stacktrace
> >
> 
> Muneer,
> 
> When the user closes dialog the control goes to jsp page, but the behavior 
> is strange as when I try subsequently to do AJAX call, it does not go to 
> the server, but instead uses the cashed response.
> 
> Thanks,
> 
> Lana.
> 
> 
> 
> 
> 
> 
> From:   vEnkaTa mohAna rAo SriperumbUdUru <mo...@gmail.com>
> To:     Struts Users Mailing List <us...@struts.apache.org>
> Date:   04/10/2012 09:19 PM
> Subject:        Re: struts2 problem when file download dialog is closed
> 
> 
> 
> You are using older version Struts2.x and change filter to
> StrutsPrepareAndExecute Filter.
> 
> 
> On Wed, Apr 11, 2012 at 1:59 AM, <sv...@bnymellon.com> 
> wrote:
> 
> > Hi,
> >
> > I've created a struts2 application that creates text file and displays 
> the
> > file download dialog for the user to open or save it.
> > It works fine if the user opens or saves it, but if the user closes the
> > file download dialog the program logs the following error:
> >
> > Servlet failed with Exception
> > java.lang.IllegalStateException: Response already committed
> >        at
> > weblogic.servlet.internal.ServletResponseImpl.objectIfCommitted(Servl
> > etResponseImpl.java:1422)
> >        at
> > weblogic.servlet.internal.ServletResponseImpl.sendError(ServletRespon
> > seImpl.java:580)
> >        at
> > org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:77
> > 1)
> >        at
> > org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.jav
> > a:506)
> >        at
> > org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatc
> > her.java:395)
> >        Truncated. see log file for complete stacktrace
> > >
> >
> > My struts.xml file code is as follows:
> >
> > <action name="AdmExport" class="ConfigAction" method="export">
> >            <result name="success" type="stream">
> >            <param name="contentType">application/octet-stream</param>
> >                <param name="inputName">inputStream</param>
> >                <param
> > name="contentDisposition">attachment;filename="tempExport.txt"</param>
> >                <param name="bufferSize">1024</param>
> >           </result>
> >        </action>
> >
> > My action class code is as follows:
> >
> > import org.apache.struts2.interceptor.SessionAware;
> > import com.opensymphony.xwork2.ActionContext;
> > import com.opensymphony.xwork2.ActionSupport;
> >
> >
> > public class ConfigAction extends ActionSupport  implements SessionAware
> > {
> >
> > public void setInputStream(InputStream inputStream) {
> >                this.inputStream = inputStream;
> >        }
> > public InputStream getInputStream() {
> >                return inputStream;
> >        }
> >
> > public String export() throws Exception {
> >
> >                try
> >                {
> >                  // code to create tempExport.txt file
> >
> >                        File exportFile = new File("./tempExport.txt");
> >                        setInputStream(new FileInputStream(exportFile));
> >                        exportFile.delete();
> >                }
> >                catch (Exception ex)
> >                {
> >                        ex.printStackTrace();
> >                }
> >
> >                return SUCCESS;
> >        }
> > }
> >
> > Any ideas as how to fix the issue will be greatly appreciated.
> >
> > Thanks,
> >
> > Svetlana Roslyakova ·  The Bank of New York Mellon
> > Regulatory Systems · Tel 212.815.8043 · 
> svetlana.roslyakova@bnymellon.com
> >
> > The information contained in this e-mail, and any attachment, is
> > confidential and is intended solely for the use of the intended 
> recipient.
> > Access, copying or re-use of the e-mail or any attachment, or any
> > information contained therein, by any other person is not authorized. If
> > you are not the intended recipient please return the e-mail to the 
> sender
> > and delete it from your computer. Although we attempt to sweep e-mail 
> and
> > attachments for viruses, we do not guarantee that either are virus-free 
> and
> > accept no liability for any damage sustained as a result of viruses.
> >
> > Please refer to http://disclaimer.bnymellon.com/eu.htm for certain
> > disclosures relating to European legal entities.
> 
> 
> The information contained in this e-mail, and any attachment, is confidential and is intended solely for the use of the intended recipient. Access, copying or re-use of the e-mail or any attachment, or any information contained therein, by any other person is not authorized. If you are not the intended recipient please return the e-mail to the sender and delete it from your computer. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses. 
> 
> Please refer to http://disclaimer.bnymellon.com/eu.htm for certain disclosures relating to European legal entities.
 		 	   		  

Re: struts2 problem when file download dialog is closed

Posted by sv...@bnymellon.com.
Venkata,

I use Struts2 2.2.1.1 version.
I've changed the filter to StrutsPrepareAndExecute Filter.

The same error:

 Servlet failed with Exception
java.lang.IllegalStateException: Response already committed
        at 
weblogic.servlet.internal.ServletResponseImpl.objectIfCommitted(Servl
etResponseImpl.java:1422)
        at 
weblogic.servlet.internal.ServletResponseImpl.sendError(ServletRespon
seImpl.java:580)
        at 
org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:77
1)
        at 
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.jav
a:506)
        at 
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(Exec
uteOperations.java:77)
        Truncated. see log file for complete stacktrace
>

Muneer,

When the user closes dialog the control goes to jsp page, but the behavior 
is strange as when I try subsequently to do AJAX call, it does not go to 
the server, but instead uses the cashed response.

Thanks,

Lana.






From:   vEnkaTa mohAna rAo SriperumbUdUru <mo...@gmail.com>
To:     Struts Users Mailing List <us...@struts.apache.org>
Date:   04/10/2012 09:19 PM
Subject:        Re: struts2 problem when file download dialog is closed



You are using older version Struts2.x and change filter to
StrutsPrepareAndExecute Filter.


On Wed, Apr 11, 2012 at 1:59 AM, <sv...@bnymellon.com> 
wrote:

> Hi,
>
> I've created a struts2 application that creates text file and displays 
the
> file download dialog for the user to open or save it.
> It works fine if the user opens or saves it, but if the user closes the
> file download dialog the program logs the following error:
>
> Servlet failed with Exception
> java.lang.IllegalStateException: Response already committed
>        at
> weblogic.servlet.internal.ServletResponseImpl.objectIfCommitted(Servl
> etResponseImpl.java:1422)
>        at
> weblogic.servlet.internal.ServletResponseImpl.sendError(ServletRespon
> seImpl.java:580)
>        at
> org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:77
> 1)
>        at
> org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.jav
> a:506)
>        at
> org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatc
> her.java:395)
>        Truncated. see log file for complete stacktrace
> >
>
> My struts.xml file code is as follows:
>
> <action name="AdmExport" class="ConfigAction" method="export">
>            <result name="success" type="stream">
>            <param name="contentType">application/octet-stream</param>
>                <param name="inputName">inputStream</param>
>                <param
> name="contentDisposition">attachment;filename="tempExport.txt"</param>
>                <param name="bufferSize">1024</param>
>           </result>
>        </action>
>
> My action class code is as follows:
>
> import org.apache.struts2.interceptor.SessionAware;
> import com.opensymphony.xwork2.ActionContext;
> import com.opensymphony.xwork2.ActionSupport;
>
>
> public class ConfigAction extends ActionSupport  implements SessionAware
> {
>
> public void setInputStream(InputStream inputStream) {
>                this.inputStream = inputStream;
>        }
> public InputStream getInputStream() {
>                return inputStream;
>        }
>
> public String export() throws Exception {
>
>                try
>                {
>                  // code to create tempExport.txt file
>
>                        File exportFile = new File("./tempExport.txt");
>                        setInputStream(new FileInputStream(exportFile));
>                        exportFile.delete();
>                }
>                catch (Exception ex)
>                {
>                        ex.printStackTrace();
>                }
>
>                return SUCCESS;
>        }
> }
>
> Any ideas as how to fix the issue will be greatly appreciated.
>
> Thanks,
>
> Svetlana Roslyakova ·  The Bank of New York Mellon
> Regulatory Systems · Tel 212.815.8043 · 
svetlana.roslyakova@bnymellon.com
>
> The information contained in this e-mail, and any attachment, is
> confidential and is intended solely for the use of the intended 
recipient.
> Access, copying or re-use of the e-mail or any attachment, or any
> information contained therein, by any other person is not authorized. If
> you are not the intended recipient please return the e-mail to the 
sender
> and delete it from your computer. Although we attempt to sweep e-mail 
and
> attachments for viruses, we do not guarantee that either are virus-free 
and
> accept no liability for any damage sustained as a result of viruses.
>
> Please refer to http://disclaimer.bnymellon.com/eu.htm for certain
> disclosures relating to European legal entities.


The information contained in this e-mail, and any attachment, is confidential and is intended solely for the use of the intended recipient. Access, copying or re-use of the e-mail or any attachment, or any information contained therein, by any other person is not authorized. If you are not the intended recipient please return the e-mail to the sender and delete it from your computer. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses. 

Please refer to http://disclaimer.bnymellon.com/eu.htm for certain disclosures relating to European legal entities.

Re: Need Help On Writing JUnit / Http Unit test case for Struts 2 Application

Posted by Maurizio Cucchiara <mc...@apache.org>.
Did you already take a look at [1]. Further, this is a very simple
example based on my recent code [2]

HTH

[1] https://cwiki.apache.org/confluence/display/WW/Struts+2+JUnit+Plugin+Tutorial
[2] https://gist.github.com/2357648

Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara

Maurizio Cucchiara


On 11 April 2012 09:19, <ch...@accenture.com> wrote:
>
> Hi All -
>
> My Team is using Struts 2 to build a web application. As a part of writing unit test case for web application , I need a small favour.
> Can Anyone provide me any small POC or Sample code to run JUNIT for Struts2 Application[Using Security Interceptor etc ]or any Http Unit test Case
> Sample.
>
> It would be of great help for me.
>
> Regards,
> Chiranjib
>
> ________________________________
> Subject to local law, communications with Accenture and its affiliates including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with Accenture policy.
> ______________________________________________________________________________________
>
> www.accenture.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Need Help On Writing JUnit / Http Unit test case for Struts 2 Application

Posted by ch...@accenture.com.
Hi All -

My Team is using Struts 2 to build a web application. As a part of writing unit test case for web application , I need a small favour.
Can Anyone provide me any small POC or Sample code to run JUNIT for Struts2 Application[Using Security Interceptor etc ]or any Http Unit test Case
Sample.

It would be of great help for me.

Regards,
Chiranjib

________________________________
Subject to local law, communications with Accenture and its affiliates including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with Accenture policy.
______________________________________________________________________________________

www.accenture.com


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: struts2 problem when file download dialog is closed

Posted by vEnkaTa mohAna rAo SriperumbUdUru <mo...@gmail.com>.
You are using older version Struts2.x and change filter to
StrutsPrepareAndExecute Filter.


On Wed, Apr 11, 2012 at 1:59 AM, <sv...@bnymellon.com> wrote:

> Hi,
>
> I've created a struts2 application that creates text file and displays the
> file download dialog for the user to open or save it.
> It works fine if the user opens or saves it, but if the user closes the
> file download dialog the program logs the following error:
>
> Servlet failed with Exception
> java.lang.IllegalStateException: Response already committed
>        at
> weblogic.servlet.internal.ServletResponseImpl.objectIfCommitted(Servl
> etResponseImpl.java:1422)
>        at
> weblogic.servlet.internal.ServletResponseImpl.sendError(ServletRespon
> seImpl.java:580)
>        at
> org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:77
> 1)
>        at
> org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.jav
> a:506)
>        at
> org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatc
> her.java:395)
>        Truncated. see log file for complete stacktrace
> >
>
> My struts.xml file code is as follows:
>
> <action name="AdmExport" class="ConfigAction" method="export">
>            <result name="success" type="stream">
>            <param name="contentType">application/octet-stream</param>
>                <param name="inputName">inputStream</param>
>                <param
> name="contentDisposition">attachment;filename="tempExport.txt"</param>
>                <param name="bufferSize">1024</param>
>           </result>
>        </action>
>
> My action class code is as follows:
>
> import org.apache.struts2.interceptor.SessionAware;
> import com.opensymphony.xwork2.ActionContext;
> import com.opensymphony.xwork2.ActionSupport;
>
>
> public class ConfigAction extends ActionSupport  implements SessionAware
> {
>
> public void setInputStream(InputStream inputStream) {
>                this.inputStream = inputStream;
>        }
> public InputStream getInputStream() {
>                return inputStream;
>        }
>
> public String export() throws Exception {
>
>                try
>                {
>                  // code to create tempExport.txt file
>
>                        File exportFile = new File("./tempExport.txt");
>                        setInputStream(new FileInputStream(exportFile));
>                        exportFile.delete();
>                }
>                catch (Exception ex)
>                {
>                        ex.printStackTrace();
>                }
>
>                return SUCCESS;
>        }
> }
>
> Any ideas as how to fix the issue will be greatly appreciated.
>
> Thanks,
>
> Svetlana Roslyakova ·  The Bank of New York Mellon
> Regulatory Systems · Tel 212.815.8043 · svetlana.roslyakova@bnymellon.com
>
> The information contained in this e-mail, and any attachment, is
> confidential and is intended solely for the use of the intended recipient.
> Access, copying or re-use of the e-mail or any attachment, or any
> information contained therein, by any other person is not authorized. If
> you are not the intended recipient please return the e-mail to the sender
> and delete it from your computer. Although we attempt to sweep e-mail and
> attachments for viruses, we do not guarantee that either are virus-free and
> accept no liability for any damage sustained as a result of viruses.
>
> Please refer to http://disclaimer.bnymellon.com/eu.htm for certain
> disclosures relating to European legal entities.