Re: Accessing resource in WEB-INF outside servlet

2004-11-08 Thread Dakota Jack
I am not sure where this discussion is coming from or going, but I have no difficulty with reading resources inside WEB-INF. First, I use a Classpath class and the given classloaders something like the following: package com.whatever.classpath; public final class Classpath { public

Re: Accessing resource in WEB-INF outside servlet

2004-11-08 Thread Steven J. Owens
David Evans wrote: > >so how do you handle this? do you pass in the connection info to every > >DAO method, like this: > >public static Book getBook(String connection, String bookId) > >public static void updateBook(String connection, Book book) > >that seems tedious, and since the all of my databa

RE: Accessing resource in WEB-INF outside servlet

2004-11-08 Thread David Evans
Thanks again for the help, this approach is very clean, and i'll be using it. dave On Mon, 2004-11-08 at 10:15, Shapira, Yoav wrote: > Hi, > >So the intialization of this sington datasource provider occurs the > >first time the class is called? and from then on out there's only one > >instance o

RE: Accessing resource in WEB-INF outside servlet

2004-11-08 Thread Shapira, Yoav
Hi, >So the intialization of this sington datasource provider occurs the >first time the class is called? and from then on out there's only one >instance of the class, owing to its singleton nature? would that look >like this: > >public class AppDBConnector { > private static final INSTANCE

RE: Accessing resource in WEB-INF outside servlet

2004-11-08 Thread David Evans
On Mon, 2004-11-08 at 09:35, Shapira, Yoav wrote: > Hi, > > >so how do you handle this? do you pass in the connection info to every > >DAO method, like this: > >public static Book getBook(String connection, String bookId) > >public static void updateBook(String connection, Book book) > > > >that s

RE: Accessing resource in WEB-INF outside servlet

2004-11-08 Thread Shapira, Yoav
Hi, >so how do you handle this? do you pass in the connection info to every >DAO method, like this: >public static Book getBook(String connection, String bookId) >public static void updateBook(String connection, Book book) > >that seems tedious, and since the all of my database You can have the

RE: Accessing resource in WEB-INF outside servlet

2004-11-08 Thread David Evans
Ok, thanks i will look into the getResource configuration method, it sounds like that would subsitute for the JNDI lookup cleanly. So one last thing, if you've got the time. You said: "Having each Bean get its own connection path itself is not clean, but it's your design, so it's up to you." so ho

RE: Accessing resource in WEB-INF outside servlet

2004-11-08 Thread Shapira, Yoav
Hi, >public static Book getBook(String bookId) >public static void updateBook(Book book) > >So in order to preserve that cleanliness, the methods have to get the >connection path themselves, which was why i was so excited by the JNDI >lookup. Having each Bean get its own connection path itself i

RE: Accessing resource in WEB-INF outside servlet

2004-11-08 Thread David Evans
Thanks for the reply. So the next question of course is, what is a better approach? I understand idea of using putting an object in the ServletContext during application initialization, but that leads to other problems. Well, to be specific, heres the problem i have with that in my application:

RE: Accessing resource in WEB-INF outside servlet

2004-11-08 Thread Shapira, Yoav
Hi, >Is using JNDI to access a file like this a reasonable approach? I just It's an OK approach. Not great, but not terrible either. The reasons it's not great are: - It's heavyweight (JNDI resource binding and resolution is typically several times more resource consuming than a static resourc

RE: Accessing resource in WEB-INF outside servlet

2004-11-08 Thread David Evans
Is using JNDI to access a file like this a reasonable approach? I just started using JNDI to name my database connections via a connection pool. And when i saw the simplicity of accessing the JNDI context within my java classes, i got to thinking that i should use it to access many of my applicatio

RE: Accessing resource in WEB-INF outside servlet

2004-11-08 Thread Shapira, Yoav
Hi, Then you have a screwed up design. There's no portable way to get the ServletContext to fit your needs, and there's no way to make Class#getResource read /WEB-INF unless you write a custom ClassLoader. Change your approach. Yoav Shapira http://www.yoavshapira.com >-Original Message-