Page 2 of 2 FirstFirst 12
Results 21 to 30 of 30
  1. #21
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,820
    Rep Power
    19

    Default Re: Best way to access and display bean object data?

    Include it as part of your project.
    Stick it in your(/a) src directory, and eclipse should then include it in your deployment.
    Then refer to it based on its location in that directory.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  2. #22
    Join Date
    Aug 2011
    Posts
    62
    Rep Power
    0

    Default Re: Best way to access and display bean object data?

    Here is my Eclipse directory structure: Best way to access and display bean object data?-dirstruc.jpg

    The XML is loaded in helper.BeanManager, but with "src/xml/data.xml" it can't be loaded. In a normal desktop Java application, "src/xml/data.xml" works, but here it doesn't.
    Last edited by noodle_variation_187-X; 06-18-2012 at 05:32 PM.

  3. #23
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,820
    Rep Power
    19

    Default Re: Best way to access and display bean object data?

    Because it is deployed on the server, and you need to tell Eclipse to include that directory when it deploys.
    When you run a "normal app" through Eclipse, it runs based on the project home directory.

    Personally I would cheat and stick it in your WEB-INF, possibly even straight into the classes sub-directory.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #24
    Join Date
    Aug 2011
    Posts
    62
    Rep Power
    0

    Default Re: Best way to access and display bean object data?

    When the files are created, they are at first in the Eclipse project folder. Later, when the application is started, the files are copied to the server folders, but I haven't yet understood quite well how the Eclipse projekt structure is mapped to the deployment structure on the server.

    My path is "/data.xml". I copied the XML-file to WEB-INF, to ROOT and to WEB-INF/classes, but the file couldn't be found.

  5. #25
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,820
    Rep Power
    19

    Default Re: Best way to access and display bean object data?

    I would get hold of Tomcat or some other external server.
    Then run it up on that./
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #26
    Join Date
    Aug 2011
    Posts
    62
    Rep Power
    0

    Default Re: Best way to access and display bean object data?

    I found a solution:
    Java Code:
    ServletContext context = getServletContext();
    InputStream input = getServletContext().getResourceAsStream(
    	"/xml/data.xml");
    This works for all kind of resources.

  7. #27
    Join Date
    Aug 2011
    Posts
    62
    Rep Power
    0

    Default Re: Best way to access and display bean object data?

    Normally shared data is stored in the application object. Why did you recommend to use a singleton object here? Is a custom-made singleton maybe more lightweight?

  8. #28
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,820
    Rep Power
    19

    Default Re: Best way to access and display bean object data?

    What do you mean by "application object"?

    I suggested a singleton as you had a requirement to load static data into a bunch of objects that you would then access during the run of the application.
    That static data was to be loaded by the time the first thing needing it tried to access it.

    It's more standard than the technique you were attempting.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #29
    Join Date
    Aug 2011
    Posts
    62
    Rep Power
    0

    Default Re: Best way to access and display bean object data?

    I thought of saving the object in application scope by using
    Java Code:
    application.setAttribute(String objName, Object object
    ).

    BTW, is there any possibility to test locally if one's application is threadsafe?

  10. #30
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,820
    Rep Power
    19

    Default Re: Best way to access and display bean object data?

    The application scope is rarely used directly.
    You'll see application properties, but they're rarely added to and removed from that scope by you.

    Testing thread safety of an app is difficult to do.
    It's more about simply not doing certain things in the first place (like giving Servlets attributes).
    If you're concerned about a particular thing you could make it synchronised, I suppose.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Page 2 of 2 FirstFirst 12

Similar Threads

  1. JMS stand alone client access remote server message driven bean
    By jane007 in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 04-05-2012, 06:10 AM
  2. Replies: 0
    Last Post: 08-13-2010, 11:20 PM
  3. Remote - Bean Access
    By haneeshrawther in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 12-07-2009, 05:48 AM
  4. Access Remote Session Bean from an separate web app
    By kiyoharatakuya in forum Enterprise JavaBeans (EJB)
    Replies: 4
    Last Post: 04-24-2009, 03:46 PM
  5. Replies: 1
    Last Post: 03-13-2008, 02:36 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •