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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:30:00+00:00 2026-06-18T16:30:00+00:00

I have checked the tutorials and this should work but it doesn’t. I have

  • 0

I have checked the tutorials and this should work but it doesn’t. I have a string in one class that I want to use in another, but when I do, I get a null exception.

@ViewScoped
@ManagedBean
public class FileDirectoryViewer {
FileUploadController destination = new FileUploadController();

        NewDestination = destination + username + "/";

And I am trying to get the destination from

@ViewScoped
@ManagedBean(name = "fileUploadController")
public class FileUploadController {

    public String destination  = "D:/Documents/NetBeansProjects/printing~subversion/fileupload/Uploaded/"; // main location for uploads

How do I get the destination from FileUploadController to FileDirectoryViewer?

  • 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-18T16:30:02+00:00Added an answer on June 18, 2026 at 4:30 pm

    The destination field of FileUploadController, has no access modifier, so it is package private by default.

    If those two classes are in the same package, you can access it by creating an instance of the class, and using the . operator on the instance to access the property:

    FileUploadController controller = new FileUploadController();
    NewDestination = controller.destination + username + "/";
    

    If they are not, you should implement a public String getDestination() method in FileUploadController that would return destination. You should call this method also by using the . operator: controller.getDestination().

    Take into account there are several issues with the code you posted:

    • You’re placing code outside a method in the FileDirectoryViewer class. In a class you can only define members (such as fields, or methods). Generally speaking, behavorial code goes inside of method declarations.

    • Using a hardcoded variable for a path property can be considered bad practice. Look into java.util.Properties for a start. Anyway, by the looks of the code, it doesn’t make sense for the destination field to be an instance field, it could be static or defined in an interface.

    • Naming conventions for java recommend variable names to be camel case, and starting with lower case letters.

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

Sidebar

Related Questions

I have checked some tutorials but I got confused by the parameters in this
I have checked this similar question, but the suggestions did not solve my problem:
So i have one old unmanaged library dll/tlb. I want to use it in
I have checked lots of tutorials on xml parsing in iOS .. but most
I have checked many questions here but none has my answer. I appreciate if
I have checked few other posts and found some UIAnimation transitions that kind-of give
I have checked out now a local working copy of a codebase that lives
I have been working in a big program and one of its functionalities should
I have checked out articles and tutorials. I don't know what to do about
I'm following one of the best tutorials/books I have ever come across, the Ruby

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.