You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by RAFA <RS...@TERRA.ES> on 2002/12/12 09:10:02 UTC

Denny access to dir webapps

Hi.

How can I deny access to webapps directory and subdirectories?
I work only with Tomcat, without Apache.

Maybe modifying tomcat.conf? ¿?¿?

Thanks.
Rafa.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [classloading] How to use URLClassLoader within a servlet

Posted by Ola Berg <ol...@ports.se>.
> Okay, I moved the JAR to $CATALINA_HOME/webapps/ROOT and changed the code to:

Great, and thanks. In about two hours I will stop the daunting task of creating a web application in VBScript/ASP (yuck) and picking up the registry-system again. I will immediately try out your way.

I suspect the magic is using the context class loader. I will try it out and let you know.

Yours grateful
/O


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [classloading] How to use URLClassLoader within a servlet

Posted by Kris Schneider <kr...@dotech.com>.
Okay, I moved the JAR to $CATALINA_HOME/webapps/ROOT and changed the code to:

URL jarURL = new URL("http://gizzard.dotech.com:8080/commons-cli-1.0.jar");

And got as output:

URL of org.apache.commons.cli.ParseException:
jar:http://gizzard.dotech.com:8080/commons-cli-1.0.jar!/org/apache/commons/cli/ParseException.class

I don't see why it wouldn't work in general from any other external URL. Do you
need this to work across firewalls?

Quoting Ola Berg <ol...@ports.se>:

> 
> > As an experiment, I created a directory under WEB-INF called "ext" and
> dumped a'
> > JAR file in it (commons-cli-1.0.jar). Then I created a servlet that did:
> 
> [snip]
> 
> > Which is just the kind of thing you want, yes?
> 
> No, you cheated ;-) You put the jar file in the WEB-INF. Strictly, we want it
> anywhere on the web.
> 
> But it is interesting. If one can use different dirs instead of ext/ ("org/",
> "info/) etc, in parallel, without creating any conflicts, that could be some
> kind of solution. 
> 
> /O
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [classloading] How to use URLClassLoader within a servlet

Posted by Ola Berg <ol...@ports.se>.
> As an experiment, I created a directory under WEB-INF called "ext" and dumped a'
> JAR file in it (commons-cli-1.0.jar). Then I created a servlet that did:

[snip]

> Which is just the kind of thing you want, yes?

No, you cheated ;-) You put the jar file in the WEB-INF. Strictly, we want it anywhere on the web.

But it is interesting. If one can use different dirs instead of ext/ ("org/", "info/) etc, in parallel, without creating any conflicts, that could be some kind of solution. 

/O


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [classloading] How to use URLClassLoader within a servlet

Posted by Kris Schneider <kr...@dotech.com>.
As an experiment, I created a directory under WEB-INF called "ext" and dumped a
JAR file in it (commons-cli-1.0.jar). Then I created a servlet that did:

URL jarURL = getServletContext().getResource("/WEB-INF/ext/commons-cli-1.0.jar");
URL[] urls = { jarURL };

ClassLoader ctxClassLoader = Thread.currentThread().getContextClassLoader();
URLClassLoader urlClassLoader = new URLClassLoader(urls, ctxClassLoader);

String className = "org.apache.commons.cli.ParseException";
String classResourceName = className.replace('.', '/') + ".class";
Class cls = urlClassLoader.loadClass(className);
System.out.println("URL of " + cls.getName() + ": " +
cls.getClassLoader().getResource(classResourceName));

On TC 4.1.16, the output was:

URL of org.apache.commons.cli.ParseException:
jar:jndi:/localhost/WEB-INF/ext/commons-cli-1.0.jar!/org/apache/commons/cli/ParseException.class

Which is just the kind of thing you want, yes?

Quoting Ola Berg <ol...@ports.se>:

> > I have an analogous case, in which I have a single API for database 
> > access, with choice of database (Oracle, MySQL,...) made at run-time. 
> > The problem was simply solved using the 'Abstract Factory' pattern. This 
> > means that I have two packages (....db.MySql, & ....db.Oracle), which 
> > both include an implementation of a DBFactory. I then use ClassForName() 
> > to load the appropriate implementation, and then call factory methods to 
> >   instantiate the appropriate classes.
> 
> But I need to bother with class loaders. The classes have the same name but
> different implementations. This resides outside of my control. Solution (in
> the standalone app) is to load the implementations on demand using different
> URLClassLoaders.
> 
> /O
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [classloading] How to use URLClassLoader within a servlet

Posted by Ola Berg <ol...@ports.se>.
> I have an analogous case, in which I have a single API for database 
> access, with choice of database (Oracle, MySQL,...) made at run-time. 
> The problem was simply solved using the 'Abstract Factory' pattern. This 
> means that I have two packages (....db.MySql, & ....db.Oracle), which 
> both include an implementation of a DBFactory. I then use ClassForName() 
> to load the appropriate implementation, and then call factory methods to 
>   instantiate the appropriate classes.

But I need to bother with class loaders. The classes have the same name but different implementations. This resides outside of my control. Solution (in the standalone app) is to load the implementations on demand using different URLClassLoaders.

/O


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [classloading] How to use URLClassLoader within a servlet

Posted by Martin Jacobson <ma...@libero.it>.
Ola Berg wrote:
 > I have this problem with using my own (URLClassLoader) class loader
 > in a servlet of mine.
 >
 > The thing is that I am writing a web front end to domain name
 > services (automatic registration of .org, .com. .biz, .info etc
 > domains).
 >
 > Depending on the top level domain, I need to use different versions
 > (jars) of the same API, since the protocol differs. So I need to
 > dynamically load my classes at runtime. Just putting the jars in lib
 > won't work since there are different implementations of the same
 > classes in them. I have to decide in runtime.
 >
 > Using the URLClassLoader in a standalone app works perfectly, when
 > using it in a servlet it just hangs. I suspect the problem lies
 > within the different lookup order used in servlets (as dscribed in
 > the classloader-HOWTO).
 >
 > I can't figure out how to do it.
 >
 > Has anyone experience in the field?
 >
I have an analogous case, in which I have a single API for database 
access, with choice of database (Oracle, MySQL,...) made at run-time. 
The problem was simply solved using the 'Abstract Factory' pattern. This 
means that I have two packages (....db.MySql, & ....db.Oracle), which 
both include an implementation of a DBFactory. I then use ClassForName() 
to load the appropriate implementation, and then call factory methods to 
  instantiate the appropriate classes.

Hence, you don't need to bother with custom classloaders, and your 
design is much 'cleaner' as a result.

HTH,

Martin


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


[classloading] How to use URLClassLoader within a servlet

Posted by Ola Berg <ol...@ports.se>.
I have this problem with using my own (URLClassLoader) class loader in a servlet of mine.

The thing is that I am writing a web front end to domain name services (automatic registration of .org, .com. .biz, .info etc domains).

Depending on the top level domain, I need to use different versions (jars) of the same API, since the protocol differs. So I need to dynamically load my classes at runtime. Just putting the jars in lib won't work since there are different implementations of the same classes in them. I have to decide in runtime.

Using the URLClassLoader in a standalone app works perfectly, when using it in a servlet it just hangs. I suspect the problem lies within the different lookup order used in servlets (as dscribed in the classloader-HOWTO). 

I can't figure out how to do it. 

Has anyone experience in the field?

/O





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>