Re: getResourceAsStream() without ServletContext?

Discussion in 'Java' started by iksrazal, Jul 17, 2003.

  1. iksrazal

    iksrazal Guest

    "Ben_" <> wrote in message news:<3f15b5b8$0$6531$>...
    > What about this.getClass().getClassLoader().getResourceAsStream() ? If the
    > class is used loaded by a servlet, your class will WEB-INF/classes in its
    > classpath. In fact, your class will have the same classpath as the
    > classloader that loaded you.
    >
    > Alternatively, you can add a setClassLoader(ClassLoader cl) method on your
    > generic class and use the classloader the client tells you to use.


    Tried that, thanks though. The problem in this case is that only
    WEB-INF/classes is in the classpath - I need to access WEB-INF/somedir
    .. Any class-based solution can't access a non-classes dir under
    WEB-INF, I'm thinking.

    iksrazal
    iksrazal, Jul 17, 2003
    #1
    1. Advertising

  2. iksrazal

    Ben_ Guest

    I used to print out all servlet context variables and IIRC, I saw one with
    the servlet classpath. I think the root directory of the WAR file is in the
    classpath. Thus WEB-INF/somedir/my.properties would be accessible. I should
    double check, but I can't right now.
    Ben_, Jul 17, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rick Roberts
    Replies:
    0
    Views:
    381
    Rick Roberts
    Aug 10, 2003
  2. RJGraham
    Replies:
    3
    Views:
    3,312
    Huang Kai
    Nov 27, 2003
  3. natG
    Replies:
    6
    Views:
    612
  4. Replies:
    2
    Views:
    10,319
  5. janne
    Replies:
    0
    Views:
    610
    janne
    Apr 5, 2005
Loading...

Share This Page