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

  • Home
  • SEARCH
  • 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 8691477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:07:45+00:00 2026-06-13T00:07:45+00:00

I have written a small CMS for an application which provides basic site management

  • 0

I have written a small CMS for an application which provides basic site management features like wysiwyg content and template editing. Pages are stored as facelets in the database and presented to the client using a custom url resolver (see last post on https://community.jboss.org/message/495515#495515), which worked really well until I started supporting different page trees for different domains served by the same application (a bit like apache’s vhosts).

So http://firstdomain/cms/page.xhtml should lead to a different page than http://seconddomain/cms/page.xhtml. The problem here is, that URLs resolved by my custom DefaultResourceResolver (and any other resolver, too) are cached by JSF only using the path (/cms/page.xhtml). So whatever domain is queried first, provides the cached URL for all requests to the same path, independent of the requested domain.

It took me quite some time to nail this problem down to the caching but now I am stuck. Is there any way to change/override/disable JSF’s URL caching to respect the requested domain name?

Update 1: I just read the myfaces implementation of FaceletCacheImpl.java and noticed that URLs are itself the key to their cache and not only their path. This leads to the problem discussed here: Why does java.net.URL's hashcode resolve the host to an IP? – URL’s are compared using their IP address and not the hostname. So still, I have to change Facelets caching behaviour.

Update 2: Experimenting with the URL parameters convinced me that they are indeed cached only by their path besides what I’ve seen in FaceletCacheImpl.java so Update 1 can be ignored.

  • 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-13T00:07:46+00:00Added an answer on June 13, 2026 at 12:07 am

    Some more research pointed me to DefaultFaceletFactory.java, which is responsible for calling the registered url resolver and caching the resolved URLs. As the class is final, it was not possible to extend it so I downloaded the latest jsf-facelets source from jboss and modified it directly by appending the current request host to the cache key. This is my replacement for public Facelet getFacelet(String uri):

    public static HttpServletRequest getRequest() {
        return (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
    }
    
    /**
     * Returns the host name from the current request.
     *
     * @return
     */
    public static String getRequestHost() {
        HttpServletRequest request = getRequest();
        if (request == null) {
            return null;
        }
        String result = request.getHeader("x-forwarded-host");
        if (result == null || result.isEmpty()) {
            result = request.getHeader("host");
        }
        return result;
    }
    
    
    /*
     * (non-Javadoc)
     * 
     * @see com.sun.facelets.FaceletFactory#getFacelet(java.lang.String)
     */
    public Facelet getFacelet(String uri) throws IOException, FaceletException,
            FacesException, ELException {
        String key = getRequestHost() + ":" + uri;
        URL url = (URL) this.relativeLocations.get(key);
        if (url == null) {
            url = this.resolveURL(this.baseUrl, uri);
            if (url != null) {
                Map newLoc = new HashMap(this.relativeLocations);
                newLoc.put(key, url);
                this.relativeLocations = newLoc;
            } else {
                throw new IOException("'" + uri + "' not found.");
            }
        }
        return this.getFacelet(url);
    }
    

    I must admit, this solution is pretty dirty but it gets the job done. Also, there were no changes to the facelets implementation for some time now, so updates shouldn’t be a problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have written a small form application, which contains textbox only. I have enabled
I have written a small application which will be used in my work environment
I have written a small rails app to serve up content to another site
I have written a small java application for which I need to obtain performance
I have written a small program just like hello the world , everything was
I have written a small .net Windows Forms application. And now I decided to
I have written a small function, which uses ElementTree to parse xml file,but it
I have written a small Python application where I use PyGame for displaying some
I have written a small piece of code which handles the input of a
I have written a small custom web server application in C running on Linux.

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.