Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8855429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:07:59+00:00 2026-06-14T14:07:59+00:00

To provide proper browser caching I want to get rid of the conversationContext parameter,

  • 0

To provide proper browser caching I want to get rid of the conversationContext parameter, that Apache MyFaces Orchestra adds to every request, for requests to css files.

As Bozho suggested, I’ve implemented a filter that sets the attribute Orchestra is looking for.

public class ResourceFilter implements Filter {

@Override
public void doFilter(ServletRequest request, ServletResponse theResponse, FilterChain theChain) throws IOException, ServletException {
    if(shouldNotAppendConversation(request)) {
        request.setAttribute(RequestParameterServletFilter.REQUEST_PARAM_FILTER_CALLED, Boolean.TRUE);
    }

    theChain.doFilter(request, theResponse);
}

private boolean shouldNotAppendConversation(ServletRequest theRequest) {
    HttpServletRequest aRequest = (HttpServletRequest) theRequest;
    String aPath = aRequest.getRequestURI();
    if(aPath.endsWith(".css.jsf")) {
        return true;
    }

    return false;
}

@Override
public void init(FilterConfig theFilterConfig) throws ServletException {
}

@Override
public void destroy() {
}
}

That doesn’t work the parameter is still appended to every request. While debugging, I’ve found out that the filter gets first hit by a request to the jsf site. For sure I want to include the conversation context in that request, so the filter forwards the request directly to the next filter in the chain. The next request that hits the filter (usually the request for a css file) has already the conversation context included in the request.

The strange thing is, if I modify the filter to always set the attribute, all request will not have the conversation context attribute. But that means, the conversation context is also not included in the request for the jsf site (but should).

I’ve noticed that the links to css files in the generated html of the jsf site also contains the conversation context attribute or not depending on the filter implementation. I guess for this reason the second request has already included the conversation context parameter?

I don’t understand why Orchestra is appending the conversation context parameter to every request and not just for the requests where the attribute is not set.

How can I implement the filter to work correctly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:08:00+00:00Added an answer on June 14, 2026 at 2:08 pm

    The next request (e.g. for a CSS file) hitting your filter after the request to your page has already the conversationContext parameter included just because this is how the url for this resource has been rendered by the page in the previous request.

    So the control over conversationContext should be taken at render time. The following solution is working for me with JSF 2 (I am using Mojarra 2.1.11, myfaces-orchestra-core20 1.5, RichFaces 4.1.0.Final). A special servlet filter is doing nothing but wraps HttpServletResponse with our own wrapper:

    public class RfOrchestraParamControlFilter implements Filter {
       ...
       @Override
       public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
          response = new RfOrchestraParamControlResponseWrapper((HttpServletResponse)response);
          chain.doFilter(request, response);
       }
       ...
    }
    

    The response wrapper tests the url to be encoded for being a richfaces resource and turns Orchestra’s ConversationRequestParameterProvider‘s separation mode on in the current thread for the time of encoding:

    package ...
    import javax.faces.application.ResourceHandler;
    import org.richfaces.resource.ResourceHandlerImpl;
    import org.apache.myfaces.orchestra.conversation.ConversationRequestParameterProvider;
    
    public class RfOrchestraParamControlResponseWrapper extends HttpServletResponseWrapper {
    
       public RfOrchestraParamControlResponseWrapper(HttpServletResponse httpServletResponse) {
          super(httpServletResponse);
       }
    
       @Override
       public String encodeURL(String url) {
          if (url.contains(ResourceHandler.RESOURCE_IDENTIFIER) || url.contains(ResourceHandlerImpl.RICHFACES_RESOURCE_IDENTIFIER)) {
             boolean current = ConversationRequestParameterProvider.isInSeparationMode();
             /* Disable conversationContext parameter in current thread for the time of rendering link to a resource */
             ConversationRequestParameterProvider.setInSeparationMode(true);
    
             String result = super.encodeURL(url);
    
             /* Restore */
             ConversationRequestParameterProvider.setInSeparationMode(current);
             return result;
          }
          else return super.encodeURL(url);
       }
    
    }
    

    (I’ve had to use String.contains() instead of String.startsWith() when testing the url for being a resource as context path and servlet path happen to prepend the passed url.)

    However that does not help either by this moment. The reason is that Orchestra uses its own response wrapping that takes place in its RequestParameterFacesContextFactory, and this wrapping happens after our filter is hit. In this way Orchestra’s wrapper turns out to be external to our one which results in our wrapper receiving url too late, when the url has already been intercepted and conversationContext appended.

    To avoid this we have a way to make our response wrapper external to Orchestra’s one by replacing effect from RequestParameterFacesContextFactory interceptor with RequestParameterServletFilter which actually does the same work. Unfortunately using another filter is not quite exquisite where we might not, but I don’t see another way so far.

    So, in web.xml place your filter after Orchestra’s one:

    <filter>
       <filter-name>requestParameterFilter</filter-name>
       <filter-class>org.apache.myfaces.orchestra.requestParameterProvider.RequestParameterServletFilter</filter-class>
    </filter>
    <filter>
       <filter-name>myOrchestraFilter</filter-name>
       <filter-class>mypkg.RfOrchestraParamControlFilter</filter-class>
    </filter>
    
    <filter-mapping>
       <filter-name>requestParameterFilter</filter-name>
       <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>
    <filter-mapping>
       <filter-name>myOrchestraFilter</filter-name>
       <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Selenium provide many kinds of browser driver, so I want to let the user
suppose I want to make a Flash browser game that can be played in
Provide an example for the pseudo-regex: Match every url except those from example.com and
I want to provide a button which cancels the present task, Let's say I
I'm having some thoughts about proper building my app and provide a good and
How to generate random numbers which will provide proper results on division (i.e the
Is there a 'correct' way to get the proper web address for a file
In Honeycomb the Loader APIs were introduced as the proper way to provide data
Is there any framework/engine that provide ability to draw 3d images on Canvas? I
I'm doing joins incorrectly, and haven't figured out the proper way to get the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.