It won't be possible to detect that the given request reached your application because a user hit the Back button. There is no indication in HTTP protocol that could tell you so.
Regards Łukasz wt., 25 sty 2022 o 22:58 albert kao <albertk...@gmail.com> napisał(a): > > 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> --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org