If the user presses the Back button of a browser, my application likes to
intercept that and display a text message at the current web page.
How to do that without using javascript?

The following codes show an approach with AbstractInterceptor.
Please review whether it will work.
If yes, how to get the flag or value that the Back button of a browser was
pressed?
If not, please suggest alternatives.
Thanks.


import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.StrutsStatics;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;


public class MyInterceptor extends AbstractInterceptor {
private Map<String, Object> session;

@Override
public class MyInterceptor extends AbstractInterceptor {
private Map<String, Object> session;

@Override
public String intercept(ActionInvocation invocation) throws Exception {
   final ActionContext context = invocation.getInvocationContext();
   session = context.getSession();
   HttpServletRequest request = (HttpServletRequest);
  context.get(StrutsStatics.HTTP_REQUEST);
   HttpSession httpSession = request.getSession(true);

   synchronized (httpSession) {
   //...
   }
  }
}

Struts version is 2.5.26.

<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

Reply via email to