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 8923987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:16:51+00:00 2026-06-15T07:16:51+00:00

I have a server dedicated for static contents so I don’t want to use

  • 0

I have a server dedicated for static contents so I don’t want to use the resources dir for storing javascript files but I don’t want to stop using the <h:outputScript /> tag.

How can I make that tag generate a link to my static server where the files are located instead of RES_NOT_FOUND. I don’t even need JSF to check if the files are there…

I tried: <h:outputScript name="#{requestBean.staticURL}/javascript.js"/>

To generate: <script type="text/javascript" src="http://static.server.com/javascript.js"></script>

But it generates: <script type="text/javascript" src="RES_NOT_FOUND"></script>

What can I do?

SOLUTION:
Daniel pointed me to a nice solution!

I’ve downloaded the Omnifaces’s source code and modified the org.omnifaces.resourcehandler.CDNResourceHandle.createResource(String resourceName, String libraryName) method to:

public Resource createResource(String resourceName, String libraryName) {
    final Resource resource = wrapped.createResource(resourceName, libraryName);

    if (cdnResources == null) {
        return resource;
    }

    String resourceId = ((libraryName != null) ? libraryName + ":" : "") + resourceName;

    String path = cdnResources.get(resourceId);

    if(path == null){
        if(libraryName != null){
            resourceId = libraryName + ":%";
            path = cdnResources.get(resourceId);
            if(path == null){
                return resource;
            }
            path += "/"+resourceName;
        }
        else return resource;
    }

    final String requestPath = path;

    return new ResourceWrapper() {

        @Override
        public String getRequestPath() {
            return requestPath;
        }

        @Override
        public Resource getWrapped() {
            return resource;
        }
    };
}

With this change I can add this to my web.xml file

<context-param>
    <param-name>org.omnifaces.CDN_RESOURCE_HANDLER_URLS</param-name>
    <param-value>
        somelib2:%=http://cdn.example.com/somelib2,
        js/script1.js=http://cdn.example.com/js/script1.js,
        somelib:js/script2.js=http://cdn.example.com/somelib/js/script2.js,
        otherlib:style.css=http://cdn.example.com/otherlib/style.css,
        images/logo.png=http://cdn.example.com/logo.png
   </param-value>
</context-param>

Notice the somelib2:%=http://cdn.example.com/somelib2, this will point any resource in somelib2 library to the relative path in http://cdn.example.com/somelib2, for example:

<h:outputScript name="js/myjs.js" library="somelib2" />

will output:

<script type="text/javascript" src="http://cdn.example.com/somelib2/js/myjs.js"></script>

This works with <h:outputScript /><h:outputStylesheet /><h:graphicImage />, anything that use resources;

  • 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-15T07:16:52+00:00Added an answer on June 15, 2026 at 7:16 am

    You can’t

    Simply because <h:outputScript /> can read only form local resource folder inside your web app

    What you could do is use Omnifaces CDNResourceHandler , and here is the JavaDoc

    It will allow you to use with a remote file

    Here some code from the showcase

    To get it to run, this handler needs be registered as follows in faces-config.xml:

    <application>
        <resource-handler>org.omnifaces.resourcehandler.CDNResourceHandler</resource-handler>
    </application>
    
    
    
    <context-param>
        <param-name>org.omnifaces.CDN_RESOURCE_HANDLER_URLS</param-name>
        <param-value>
            js/script1.js=http://cdn.example.com/js/script1.js,
            somelib:js/script2.js=http://cdn.example.com/somelib/js/script2.js,
            otherlib:style.css=http://cdn.example.com/otherlib/style.css,
            images/logo.png=http://cdn.example.com/logo.png
        </param-value>
    </context-param>
    

    With the above configuration, the following resources:

    <h:outputScript name="js/script1.js" />
    <h:outputScript library="somelib" name="js/script2.js" />
    <h:outputStylesheet library="otherlib" name="style.css" />
    <h:graphicImage name="images/logo.png" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have access to a dedicated server and want to finally create my
I currently have a virtual dedicated server through Media Temple that I use to
I want to convert and show video that user uploaded. I have dedicated server
I want to create website thumbnails (screenshots) using php. I have a dedicated server
Currently I have a dedicated server with WHM and Joomla running. I want to
Good evening, I have a Dedicated Server in a data center and i want
I have a dedicated server and I'm in need for building new version of
I have MVC3 installed on my dedicated server and I have an mvc3 website
I have just moved a site from a dedicated server to a GoDaddy shared
I have a myisam only dedicated 32 GB RAM mysql server that is running

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.