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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:09:57+00:00 2026-05-27T02:09:57+00:00

my requirement is as follows: INFO: icefaces upload component, uploads the files to relative

  • 0

my requirement is as follows:

INFO: icefaces upload component, uploads the files to relative folder and creates for each user a sub-directory in that folder with the sessionId.

Requirement: at the sessionDestroyed for each user, i want to get the real path, to delete current user folder.

i know how to get the real path with JSF as follows:

ServletContext ctx = (ServletContext) FacesContext.getCurrentInstance()
                .getExternalContext().getContext();
        String deploymentDirectoryPath = ctx.getRealPath("/");

Problem: if you try to get the real path in sessionDestroyed you will get null pointer exception, so i was wondering if there’s a way to initialize the variable deploymentDirectoryPath in the listener so i can use it in sessionDestroyed method, or maybe initialize the real path variable on application startup and use it here ?

please advise how to solve this issue.

  • 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-27T02:09:58+00:00Added an answer on May 27, 2026 at 2:09 am

    Even though you haven’t posted the actual code that relates to the problem, the following gives me the real path:

    public class MySessListener implements HttpSessionListener {
    
        @Override
        public void sessionCreated(final HttpSessionEvent se) {
            System.out.println(Thread.currentThread().getStackTrace()[1]);
            new Timer().schedule(new TimerTask() {
    
                @Override
                public void run() {
                    HttpSession sess = se.getSession();
                    sess.invalidate();
                }
            }, 10000);
        }
    
        @Override
        public void sessionDestroyed(HttpSessionEvent se) {
            System.out.println(Thread.currentThread().getStackTrace()[1]);
            String realPath = se.getSession().getServletContext().getRealPath("/");
            System.out.println("realPath: " + realPath);
        }
    }
    

    Output

    INFO: com.bhesh.demo.web.listener.MySessListener.sessionCreated(MySessListener.java:13)
    INFO: com.bhesh.demo.web.listener.MySessListener.sessionDestroyed(MySessListener.java:26)
    INFO: realPath: C:\Documents and Settings\Bhesh\My Documents\NetBeansProjects\JsfMessageList\build\web\
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to implement something as follows: The user uploads different types of files
I have a requirement like follows, in this there will be list of user
I have a requirement as follows. I have a directory for eg i have
Requirement is like: I want to take input values from user in frame but
My Requirement is as follows. Take a photo using webcam and provide an edit
I have a requirement for a set of asp.net MVC websites as follows: Multiple
Hi normally in Log4j priority levels are as follows DEBUG < INFO < WARN
I have to implement a strange requirement that goes as follows: Users can hover
My requirement is if the user click on update data with out changing any
I have a requirement to search for a user in an OU. My solution

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.