简体   繁体   中英

Getting redirected to page which is not defined in struts.xml action after calling execAndWait interceptor

After uploading file to server the server do some processing which takes some time. Hence I'm using execute and wait interceptor to prevent time out.

But the problem is once the execAndWait is called the page is getting redirected to exception.jsp but on the server end I'm not getting any exception at all. The process in running smoothly at server end.

Also there is no result defined for exception.jsp in struts.xml.

Struts.xml

  <action name="Process" class="fpoActions.Process" method="execute">
        <interceptor-ref name="defaultStack">
            <param name="fileUpload.maximumSize">150971520</param>
        </interceptor-ref>
        <interceptor-ref name="completeStack" />
        <interceptor-ref name="execAndWait" />
        <result name="wait">WEB-INF/fpo/longRunningAction-wait.jsp</result>
        <result name="success">WEB-INF/fpo/DownloadFpo.jsp</result>
        <result name="input">WEB-INF/fpo/fpoAnalysis.jsp</result>
    </action>

Action class

public String execute(){

        String appPath=request.getServletContext().getRealPath("")+"\\WEB-INF\\Data";
        try{
            System.out.println("DestinationLoc:"+appPath);
            System.out.println("Source File Name:"+fileFileName);
            File destFile  = new File(appPath, fileFileName);
            System.out.println(month+" "+year);
            FileUtils.copyFile(file, destFile);
            System.out.println("File Copied");
            System.out.println(destFile.getAbsolutePath());
            System.out.println(appPath);

            String t=utils.LogUtils.generateData(month,year,appPath,destFile.getAbsolutePath(),appPath);

            System.out.println("OutPut:"+t);
            System.out.println(new File(t).exists());
        }catch(Exception ex){
            addActionMessage("User Attributes file is not valid!!");
            ex.printStackTrace();
            return "input";
        }
        return "success";
    }

longRunningAction-wait.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<head>
  <title>Processing</title>
  <meta charset="utf-8">
  <meta http-equiv="refresh" content="5;url=<s:url includeParams="all" />"/>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
 <style type="text/css">
  div#header,div#footer,div#content,div#post {
    border:1px solid grey;
    margin:5px;margin-bottom:5px;padding:8px;
    background-color:white;
}
div#header,div#footer {
    color:white;background-color:#444;margin-bottom:5px;
}
div#footer {
   position:fixed;
   left:0px;
   bottom:0px;
   height:30px;
   width:100%;
   background:#444;
}
  .logoutLblPos{

   position:fixed;
   left:10px;
   top:5px;
}
</style>
</head>
<body>
<div id="header">
<h1 align="center"> Automation</h1>
</div>
<div class="container">
  <h2 align="center">Please Wait while we process your Data...</h2>
  <div class="progress" align="center">
    <div align="center" class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:40%">
      40%
    </div>
  </div>
</div>
<div id="footer">

</div>
</body>
</html>

Issue resolved after making following changes in struts.xml

Removed completeStack interceptor and replaced defaultStack with completeStack interceptor.

 <action name="Process" class="fpoActions.Process" method="execute">
            <interceptor-ref name="completeStack">
                <param name="fileUpload.maximumSize">150971520</param>
            </interceptor-ref>
            <interceptor-ref name="execAndWait" />
            <result name="wait">WEB-INF/fpo/longRunningAction-wait.jsp</result>
            <result name="success">WEB-INF/fpo/DownloadFpo.jsp</result>
            <result name="input">WEB-INF/fpo/fpoAnalysis.jsp</result>
        </action>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM