Quantcast

[GitHub] struts pull request #125: Immutable context

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] struts pull request #125: Immutable context

lukaszlenart-2
GitHub user lukaszlenart opened a pull request:

    https://github.com/apache/struts/pull/125

    Immutable context

    WIP

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/lukaszlenart/struts immutable-context

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/struts/pull/125.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #125
   
----
commit 7627b835556b0ecbd945a3ae1f27693eec41969f
Author: Lukasz Lenart <[hidden email]>
Date:   2017-03-24T09:34:39Z

    Moves documentation to wiki

commit 9d330eee27ba6c74d1fcb8d0c6223d322af9f11b
Author: Lukasz Lenart <[hidden email]>
Date:   2017-03-24T10:02:35Z

    Uses OGNL without #context magical key

commit dc2f122d9e4bb66605e4ea9f8cd2c9683c8c0819
Author: Lukasz Lenart <[hidden email]>
Date:   2017-03-24T10:03:30Z

    Adjusts OGNL usage to avoid modify immutable context

----


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] struts issue #125: Immutable context

lukaszlenart-2
Github user cnenning commented on the issue:

    https://github.com/apache/struts/pull/125
 
    Sounds like a very good idea! A short check showed that my apps are not affected 😆


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] struts issue #125: Immutable context

lukaszlenart-2
In reply to this post by lukaszlenart-2
Github user yasserzamani commented on the issue:

    https://github.com/apache/struts/pull/125
 
    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 java.io.IOException;
   
    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;
   
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    MYUtils = new MYUtils();
    }
   
    @Override
    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);
    }
   
    @Override
    public void destroy() {
    MYUtils = null;
    }
   
   
    public class MYUtils {
    public String getRequestURI() {
    HttpServletRequest httpsr = ((HttpServletRequest) ActionContext.getContext()
    .get(StrutsStatics.HTTP_REQUEST));
    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 [hidden email] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...