RE: How do I access files above and below \web-inf folder?

2002-12-02 Thread Shapira, Yoav
Howdy,
Use a ServletContextListener and load these things in the contextInitialized() method. 
 The ServletContextEvent has a reference to the ServletContext.

Yoav Shapira
Millennium ChemInformatics


>-Original Message-
>From: Esteban González [mailto:[EMAIL PROTECTED]]
>Sent: Monday, December 02, 2002 11:38 AM
>To: Tomcat Users List
>Subject: Re: How do I access files above and below \web-inf folder?
>
>Hi,
>What if I don´t have a way to access to any kind of ServletContext.?
>
>Let´s say i have a static class that loads properties, but i want it to
>use ServletContext.getResource(..). Unfortunately there´s no static method
>around to the a reference to the servletContext.
>
>any ideas?
>
>Best regards,
>Esteban
>
>- Original Message -
>From: "Tim Moore" <[EMAIL PROTECTED]>
>To: "Tomcat Users List" <[EMAIL PROTECTED]>
>Sent: Monday, December 02, 2002 1:31 PM
>Subject: RE: How do I access files above and below \web-inf folder?
>
>
>You should probably use ServletContext.getResource or
>ServletContext.getResourceAsStream
>
>http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletConte
>xt.html#getResource(java.lang.String)
>
>http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletConte
>xt.html#getResourceAsStream(java.lang.String)
>
>That way, it will still work if your web app is packaged as a WAR file.
>The path argument is context-relative.
>
>--
>Tim Moore / Blackboard Inc. / Software Engineer
>1899 L Street, NW / 5th Floor / Washington, DC 20036
>Phone 202-463-4860 ext. 258 / Fax 202-463-4863
>
>
>> -----Original Message-
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>> Sent: Monday, December 02, 2002 5:06 AM
>> To: Tomcat Users List
>> Subject: RE: How do I access files above and below \web-inf folder?
>>
>>
>>
>> I use the getRealPath,
>>
>> String pathToPropsFile = config.getServletContext().getRealPath
>> ("WEB-INF/properties/");
>>
>> use "/", as this also works on win platforms, and does not
>> need escaping. You should be able to use a relative going up
>> the tree, in the argument ("../foo/bar");
>>
>> cheers,
>>
>> Mehdi
>
>--
>To unsubscribe, e-mail:
><mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail:
><mailto:[EMAIL PROTECTED]>
>
>
>--
>To unsubscribe, e-mail:   <mailto:tomcat-user-
>[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:tomcat-user-
>[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: How do I access files above and below \web-inf folder?

2002-12-02 Thread Cédric Viaud
Or better than a servlet (wich can stop and re-start for many reasons on the
Servlet Container) use a "listener" if you use 2.3 servlet version. Easy to
implements, and certainly safer then using the init() method of a servlet.

See the servlet specification SRV.10.2

Hope it helps,

   Cédric
- Original Message -
From: "Tim Moore" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>; "Esteban González"
<[EMAIL PROTECTED]>
Sent: Monday, December 02, 2002 5:45 PM
Subject: RE: How do I access files above and below \web-inf folder?


> Instead of making the class static, you could load the properties from a
servlet that runs when your web application starts up.
> --
> Tim Moore / Blackboard Inc. / Software Engineer
> 1899 L Street, NW / 5th Floor / Washington, DC 20036
> Phone 202-463-4860 ext. 258 / Fax 202-463-4863
>
>
> > -Original Message-
> > From: Esteban González [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, December 02, 2002 11:38 AM
> > To: Tomcat Users List
> > Subject: Re: How do I access files above and below \web-inf folder?
> >
> >
> > Hi,
> > What if I don´t have a way to access to any kind of
> > ServletContext.?
> >
> > Let´s say i have a static class that loads properties,
> > but i want it to use ServletContext.getResource(..).
> > Unfortunately there´s no static method around to the a
> > reference to the servletContext.
> >
> > any ideas?
> >
> > Best regards,
> >     Esteban
> >
> > - Original Message -
> > From: "Tim Moore" <[EMAIL PROTECTED]>
> > To: "Tomcat Users List" <[EMAIL PROTECTED]>
> > Sent: Monday, December 02, 2002 1:31 PM
> > Subject: RE: How do I access files above and below \web-inf folder?
> >
> >
> > You should probably use ServletContext.getResource or
> > ServletContext.getResourceAsStream
> >
> http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletConte
> xt.html#getResource(java.lang.String)
>
> http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletConte
> xt.html#getResourceAsStream(java.lang.String)
>
> That way, it will still work if your web app is packaged as a WAR file.
The path argument is context-relative.
>
> --
> Tim Moore / Blackboard Inc. / Software Engineer
> 1899 L Street, NW / 5th Floor / Washington, DC 20036
> Phone 202-463-4860 ext. 258 / Fax 202-463-4863
>
>
> > -Original Message-
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, December 02, 2002 5:06 AM
> > To: Tomcat Users List
> > Subject: RE: How do I access files above and below \web-inf folder?
> >
> >
> >
> > I use the getRealPath,
> >
> > String pathToPropsFile = config.getServletContext().getRealPath
> > ("WEB-INF/properties/");
> >
> > use "/", as this also works on win platforms, and does not need
> > escaping. You should be able to use a relative going up the tree, in
> > the argument ("../foo/bar");
> >
> > cheers,
> >
> > Mehdi
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: How do I access files above and below \web-inf folder?

2002-12-02 Thread Tim Moore
Instead of making the class static, you could load the properties from a servlet that 
runs when your web application starts up.
-- 
Tim Moore / Blackboard Inc. / Software Engineer
1899 L Street, NW / 5th Floor / Washington, DC 20036
Phone 202-463-4860 ext. 258 / Fax 202-463-4863


> -Original Message-
> From: Esteban González [mailto:[EMAIL PROTECTED]] 
> Sent: Monday, December 02, 2002 11:38 AM
> To: Tomcat Users List
> Subject: Re: How do I access files above and below \web-inf folder?
> 
> 
> Hi,
> What if I don´t have a way to access to any kind of 
> ServletContext.?
> 
> Let´s say i have a static class that loads properties, 
> but i want it to use ServletContext.getResource(..). 
> Unfortunately there´s no static method around to the a 
> reference to the servletContext.
> 
> any ideas?
> 
> Best regards,
> Esteban
> 
> - Original Message -
> From: "Tim Moore" <[EMAIL PROTECTED]>
> To: "Tomcat Users List" <[EMAIL PROTECTED]>
> Sent: Monday, December 02, 2002 1:31 PM
> Subject: RE: How do I access files above and below \web-inf folder?
> 
> 
> You should probably use ServletContext.getResource or 
> ServletContext.getResourceAsStream
> 
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletConte
xt.html#getResource(java.lang.String)

http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletConte
xt.html#getResourceAsStream(java.lang.String)

That way, it will still work if your web app is packaged as a WAR file. The path 
argument is context-relative.

--
Tim Moore / Blackboard Inc. / Software Engineer
1899 L Street, NW / 5th Floor / Washington, DC 20036
Phone 202-463-4860 ext. 258 / Fax 202-463-4863


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 02, 2002 5:06 AM
> To: Tomcat Users List
> Subject: RE: How do I access files above and below \web-inf folder?
>
>
>
> I use the getRealPath,
>
> String pathToPropsFile = config.getServletContext().getRealPath
> ("WEB-INF/properties/");
>
> use "/", as this also works on win platforms, and does not need 
> escaping. You should be able to use a relative going up the tree, in 
> the argument ("../foo/bar");
>
> cheers,
>
> Mehdi

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: How do I access files above and below \web-inf folder?

2002-12-02 Thread Esteban González
Hi,
What if I don´t have a way to access to any kind of ServletContext.?

Let´s say i have a static class that loads properties, but i want it to
use ServletContext.getResource(..). Unfortunately there´s no static method
around to the a reference to the servletContext.

any ideas?

Best regards,
Esteban

- Original Message -
From: "Tim Moore" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Monday, December 02, 2002 1:31 PM
Subject: RE: How do I access files above and below \web-inf folder?


You should probably use ServletContext.getResource or
ServletContext.getResourceAsStream

http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletConte
xt.html#getResource(java.lang.String)

http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletConte
xt.html#getResourceAsStream(java.lang.String)

That way, it will still work if your web app is packaged as a WAR file.
The path argument is context-relative.

--
Tim Moore / Blackboard Inc. / Software Engineer
1899 L Street, NW / 5th Floor / Washington, DC 20036
Phone 202-463-4860 ext. 258 / Fax 202-463-4863


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 02, 2002 5:06 AM
> To: Tomcat Users List
> Subject: RE: How do I access files above and below \web-inf folder?
>
>
>
> I use the getRealPath,
>
> String pathToPropsFile = config.getServletContext().getRealPath
> ("WEB-INF/properties/");
>
> use "/", as this also works on win platforms, and does not
> need escaping. You should be able to use a relative going up
> the tree, in the argument ("../foo/bar");
>
> cheers,
>
> Mehdi

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: How do I access files above and below \web-inf folder?

2002-12-02 Thread Tim Moore
You should probably use ServletContext.getResource or
ServletContext.getResourceAsStream

http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletConte
xt.html#getResource(java.lang.String)

http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletConte
xt.html#getResourceAsStream(java.lang.String)

That way, it will still work if your web app is packaged as a WAR file.
The path argument is context-relative.

-- 
Tim Moore / Blackboard Inc. / Software Engineer
1899 L Street, NW / 5th Floor / Washington, DC 20036
Phone 202-463-4860 ext. 258 / Fax 202-463-4863


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
> Sent: Monday, December 02, 2002 5:06 AM
> To: Tomcat Users List
> Subject: RE: How do I access files above and below \web-inf folder?
> 
> 
> 
> I use the getRealPath,
> 
> String pathToPropsFile = config.getServletContext().getRealPath
> ("WEB-INF/properties/");
> 
> use "/", as this also works on win platforms, and does not 
> need escaping. You should be able to use a relative going up 
> the tree, in the argument ("../foo/bar");
> 
> cheers,
> 
> Mehdi

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: How do I access files above and below \web-inf folder?

2002-12-02 Thread Mehdi . Nejad

I use the getRealPath,

String pathToPropsFile = config.getServletContext().getRealPath
("WEB-INF/properties/");

use "/", as this also works on win platforms, and does not need escaping.
You should be able to use a relative going up the tree, in the argument
("../foo/bar");

cheers,

Mehdi



--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: How do I access files above and below \web-inf folder?

2002-12-02 Thread Reynir Hübner
Hi...
things that come to mind...

What you mention as \web-inf is always uppercase WEB-INF (java is case sensitive).
The slash should be made with a java.io.File.seperator it's / in unix and \\ in 
windows. 
\web-inf will leave you with eb-inf as a single backslash \ is an escape char. 

Hope it helps
-reynir




> -Original Message-
> From: Peter Lee [mailto:[EMAIL PROTECTED]] 
> Sent: 2. desember 2002 07:45
> To: [EMAIL PROTECTED]
> Subject: How do I access files above and below \web-inf folder?
> 
> 
> How do I access files above and below \web-inf folder  from a 
> JSP/html file that is above 
> the \web-inf folder ? I am now using getRealpath() in my jsp 
> code, but it did not work. 
> Any ideas? I am stuck now..  
> Thanks 
> 
> --
> To unsubscribe, e-mail:   
>  [EMAIL PROTECTED]>
> For 
> additional commands, 
> e-mail: 
> 
> 

--
To unsubscribe, e-mail:   
For additional commands, e-mail: