struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yasserzamani <>
Subject [GitHub] struts issue #125: Immutable context
Date Wed, 12 Apr 2017 15:09:31 GMT
Github user yasserzamani commented on the issue:
    Below is my new design which may be helpful as an example for whom is affected. Those
are about access to `%{#context['com.opensymphony.xwork2.dispatcher.HttpServletRequest'].requestURI}`.
    I wrote following Filter which operates after struts-prepare but before struts-execute.
It supplies an utility into request scope:
    package utils;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts2.StrutsStatics;
    import com.opensymphony.xwork2.ActionContext;
    import com.opensymphony.xwork2.util.ValueStack;
     * @author zamani
    public class MYStrutsPrepareFilter implements Filter {
    	private MYUtils MYUtils;
    	public void init(FilterConfig filterConfig) throws ServletException {
    		MYUtils = new MYUtils();
    	public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
    			throws IOException, ServletException {
    		ValueStack stack = ActionContext.getContext().getValueStack();
    		stack.setValue("#request['MYUtils']", MYUtils);
    		chain.doFilter(req, res);
    	public void destroy() {
    		MYUtils = null;
    	public class MYUtils {
    		public String getRequestURI() {
    			HttpServletRequest httpsr = ((HttpServletRequest) ActionContext.getContext()
    			return httpsr.getRequestURI();
    Then `"#request['MYUtils'].requestURI"` can be used in jsp, instead.

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message