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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:15:26+00:00 2026-05-30T09:15:26+00:00

Firstly, please forgive me if I have asked this before (i suffer memory problems

  • 0

Firstly, please forgive me if I have asked this before (i suffer memory problems due to a brain tumor.)

I am trying to roll a Managed Bean to fetch images from a directory, but don’t know how to get the url for iether of the following locations:

1)Maven ‘resources’ dir &
2)webapp/images dir (from withing my Managed bean.

Additionally is it still fine to use h:datatTable to display data as I understand Tables to be somewhat outdated no?

I have written a large portion of the desired bean and am just seeking info on how (if possible) to find the urls or set the url as a managed property.

package com.buhaugane.util;

/**
 * Created by IntelliJ IDEA.
 * User: Yucca http://thejarbar.org
 * Date: 2/23/12
 * Time: 10:21 AM
 * To change this template use File | Settings | File Templates.
 */


import org.apache.commons.collections.ArrayStack;

import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import java.io.File;
import java.util.Arrays;
import java.util.List;

/**
 * Contain utility methods to interact with images.
 */
@ManagedBean(name = "images")
public class ImageBean {
    List<File> images;

    static String thumbUrl;
    static String fullSizeURL;

    /**
     * Returns all thumbnails at specified url
     */
    public static List<File> thumbnails (){
        thumbUrl=//can I get it from context if I can't set url as a manages property?


        File[] files = new File(thumbUrl).listFiles();
        List<File> returnList = Arrays.asList(files);
        return returnList;
    }

    /**
     * Returns all full-sized images at specified url
     */
    public static List<File> fullSized (){
        thumbUrl=**//can I get it from context if I can't set url as a manages property?**


        File[] files = new File(thumbUrl).listFiles();
        List<File> returnList = Arrays.asList(files);
        return returnList;
    }
}

Many thanks, Yucca

  • 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-30T09:15:28+00:00Added an answer on May 30, 2026 at 9:15 am

    You could use ExternalContext#getRealPath() to convert a given relative web path to an absolute disk file system. So to get the absolute disk file system path of the /images folder in public webcontent, do as follows:

    String relativeWebPath = "/images";
    String absoluteDiskPath = FacesContext.getCurrentInstance().getExternalContext().getRealPath(relativeWebPath);
    File imagesFolder = new File(absoluteDiskPath);
    // ...
    

    You should only keep in mind that the above won’t work when the server is configured to expand WAR into memory instead of on disk. The getRealPath() would then return null in all circumstances. You’d need to look for an alternative approach, for example storing it outside the WAR on a fixed path, or very maybe in a database.


    Additionally is it still fine to use h:datatTable to display data as I understand Tables to be somewhat outdated no?

    Tables are not outdated. They are still perfect for presenting tabular data. Only using tables for layout is indeed considered bad practice as it’s not semantic and thus poor for SEO. In JSF terms, we’re then talking about using <h:panelGrid> to give the page layout (e.g. header, body, footer, etc). You should be using <div>s instead which can be generated by <h:panelGroup layout="block">.

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

Sidebar

Related Questions

Firstly, please forgive it is already asked one or can be find easily with
Firstly: I am totally a newbie for this kind of work. I have a
Firstly, I do not have any malicious intent out of this question. I would
Firstly, please go to this url: celebritywallpaperbase picture #1 is Drew Barrymore smile picture
Firstly this has turned out to be quite a long post so please bear
Firstly, if you're not using 9.1+, please refer to this question . How do
Firstly, please don't dismiss this question - I'm aware it's an ugly situation but
Firstly, I'm totally javascript inept so please explain throughly. OK, I have two issues
Firstly, what i am trying to do is have a page that users can
Firstly could someone please be kind enough to comment on why Microsoft might have

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.