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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:40:40+00:00 2026-05-27T18:40:40+00:00

I really don’t know if it’s a Netbeans issue but here’s the problem: In

  • 0

I really don’t know if it’s a Netbeans issue but here’s the problem:
In my jsf web app, in the root directory, I have a folder named resources which contains the sub folders images, css and js (for javascript). The subfolders contain the respective content. Here’s how I reference a script (for example) from within the application:

   <h:outputScript library="js" target="head" name="dialog.js"/>

Problem is, when I clean and build, while the files in the css directories and js directories are left intact, all the images in the images directory are deleted. How then can I use the jsf resource mechanism if it’ll wipe off my images on every “clean and build”?

  • 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-05-27T18:40:41+00:00Added an answer on May 27, 2026 at 6:40 pm

    JSF doesn’t do that. It’s the server which does that. This problem indicates that you’re manually storing (uploaded?) images in the expanded WAR folder instead of somewhere outside it. A “clean and rebuild” just cleans the server’s work folder and the old expanded WARs and rebuilds the webapp based on the original WAR (essentially, when developing, the project’s structure). This does by the way not only happen in development, but also in production whenever you redeploy a new WAR file.

    This behaviour is by specification. You should simply not manually put files in the expanded WAR folder and expect them to magically be included in the original WAR file or to be retained on redeploy.

    Store them in a fixed and permanent location outside the WAR. If you add the external path as a new context to the server, then you can just reference them by <img> or <h:graphicImage value> the usual way.
    See also Load images from outside of webapps / webcontext / deploy folder using <h:graphicImage> or <img> tag.

    If you really need to get them to be resolved by the JSF resource handler, so that you can use them in something like <h:graphicImage library="uploads" name="foo.png>, then you need to implement a custom ResourceHandler. It look something like this:

    public class UploadedResourceHandler extends ResourceHandlerWrapper {
    
        private ResourceHandler wrapped;
    
        public MyResourceHandler(ResourceHandler wrapped) {
            this.wrapped = wrapped;
        }
    
        @Override
        public ResourceHandler getWrapped() {
            return this.wrapped;
        }
    
        @Override
        public Resource createResource(String resourceName, String libraryName) {
            if ("uploads".equals(libraryName)) {
                return new YourCustomUploadedResourceImpl(resourceName);
            } else {
                return super.createResource(resourceName, libraryName);
            }
        }
    
    }
    

    To get it to run, register it as follows in faces-config.xml:

    <application>
        <resource-handler>com.example.UploadedResourceHandler</resource-handler>
    </application>
    

    This is however not exactly trivial to summarize off top of head in a single answer. You also need to understand how HTTP (caching) works. Just read the javadocs, starting at ResourceHandler, and peek around in Mojarra’s own ResourceHandlerImpl and ResourceImpl source codes to get the idea.

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

Sidebar

Related Questions

I have this problem and really don't know how to solve this. I'm having
I really don't know what my problem is lately, but Regex seems to be
I really don't know what I'm doing with SQL, but I have two tables.
I really don't know how to describe it, but if you understood it and
As a developer I really don't like writing documentation but when I have to
I really don't know/have the answer, knowledge to find a resource value using a
I really don't know how to title this question, but I need some help
I have this json object (which i don't really know what is inside) and
I know that the naming conventions really don't say anything about that, but I
That can be silly question but I really don't know the reason. // i

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.