I am currently working on a small web app and this is the first time i am using struts. Here is what i am trying to achieve
A JSP page on form post, calls a struts action. Once this action completes it task, I need to return to the calling JSP and refresh it repeatedly to poll for the results of this task. Please note that all my action does is to execute a java Executor.
I have this configured by specifying the calling page in the result attribute of the action definition in the struts.xml. The problem is that when the action completes its execution and returns to jsp, the url after the return is http://localhost:8080/mywebapp/dosomething.action. Now since i defined a meta tag for the page to refresh, the action is submitted everytime the page refreshes. I think its not refreshing the jsp, but its refreshing the url.
As a workaround, i have defined the result to a temporary page from which i am redirecting to this caller jsp. I am not liking this hack and would like to understand how should this problem be correctly implemented.
After you reach the JSP page, you want to request for that JSP page again and again. You don't need to go through the Action to reach to the JSP. That means that the JSP doesn't actually need anything from the action and works on its own. Is this right??
The JSP needs info from the action and also need to submit the form post to the action
This is use case. Hope it helps
1. User logs into the app and reaches test.jsp (http://.../test.jsp)
2. User submits a form post which submits to test.action
3. test action class perform some operation in a background thread
4. A "success" result should return to test.jsp
5. A "error" result should return to test.jsp with a message which I am accessing via struts2 property tag to display on test.jsp
6. The test.jsp refreshes to poll for the result of the operation from teststatusManager
The issue is that when the call returns to the jsp, the url in the browser is http://.../test.action. Due to this when the jsp refreshes to poll for the result of the operation performed from the teststatusManager, it re-submits test.action which is not the intention of the refresh.
So at step 6, you want test.jsp to poll to teststatusManager.action?? This is easy to do, you can use the meta tag to achieve this (as I think you already did in an intermediate page that you used). You just need to use a syntax like given here i.e.
Joined: Oct 27, 2002
I got your point. I split the action to submit and the action to refresh into 2. That resolved my problem. Thanks for your inputs.