You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Pawson, David" <Da...@rnib.org.uk> on 2004/11/17 13:32:21 UTC

File upload and download.

I'm using Tomcat 5.0.28.
My app relates to upload and download.
Using fileupload to upload files,
and a basic file interface to store them 
to a fixed disk location.

Presenting a webpage with a list of links,
the url needs to be within the tomcat installation
(security etc).

Question.
  How do people find out where the tomcat base
install is, CATALINA_HOME? 

My only solution so far is passing a property 
when tomcat is launched, and it does seem messy.

	try{
	    String tcHome = System.getProperty("tcHome");
	    if (tcHome==null || ){
		System.err.println("CATALINA_HOME not set");
	    }else
		System.err.println("tc at " + tcHome);
	}catch(java.lang.SecurityException err) {
	    System.err.println("Security Exception"+ err);
	}catch(java.lang.NullPointerException err) {
	    System.err.println("Property not set. Exception"+ err);
	}

Any improvements please?


Regards DaveP.

**** snip here *****

-- 
DISCLAIMER:

NOTICE: The information contained in this email and any attachments is 
confidential and may be privileged.  If you are not the intended 
recipient you should not use, disclose, distribute or copy any of the 
content of it or of any attachment; you are requested to notify the 
sender immediately of your receipt of the email and then to delete it 
and any attachments from your system.

RNIB endeavours to ensure that emails and any attachments generated by
its staff are free from viruses or other contaminants.  However, it 
cannot accept any responsibility for any  such which are transmitted.
We therefore recommend you scan all attachments.

Please note that the statements and views expressed in this email and 
any attachments are those of the author and do not necessarily represent
those of RNIB.

RNIB Registered Charity Number: 226227

Website: http://www.rnib.org.uk




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: File upload and download.

Posted by Mark Lowe <me...@gmail.com>.
What about System.getProperty("catalina.base") ? or "catalina.home" ?
they are passed to the jvm at startup.. Not sure how if or how you get
access to them.

Mark


On Wed, 17 Nov 2004 06:20:07 -0800, Dakota Jack <cr...@gmail.com> wrote:
> The following code gets you CATALINA_HOME.  I cannot tell if this will
> be helpful to you or not.  Probably not, but what the heck, David.
> 
> Jack
> 
>   package com.whatever.classpath;
> 
>   import java.io.File;
>   import java.net.URL;
> 
>   public final class Classpath {
>     public static final String HERE  =
> Classpath.class.getClassLoader().getResource(
>                                                              "com" +
> File.separator +
> 
> "whatever" + File.separator +
> 
> "classpath" + File.separator +
> 
> "Classpath.class").getFile();
>     public static final String CATALINA_HOME = HERE.substring(
>                                                                            1,
> 
>     HERE.lastIndexOf("webapp"));
>   }
> 
> On Wed, 17 Nov 2004 12:32:21 -0000, Pawson, David
> 
> 
> <da...@rnib.org.uk> wrote:
> > I'm using Tomcat 5.0.28.
> > My app relates to upload and download.
> > Using fileupload to upload files,
> > and a basic file interface to store them
> > to a fixed disk location.
> >
> > Presenting a webpage with a list of links,
> > the url needs to be within the tomcat installation
> > (security etc).
> >
> > Question.
> >   How do people find out where the tomcat base
> > install is, CATALINA_HOME?
> >
> > My only solution so far is passing a property
> > when tomcat is launched, and it does seem messy.
> >
> >         try{
> >             String tcHome = System.getProperty("tcHome");
> >             if (tcHome==null || ){
> >                 System.err.println("CATALINA_HOME not set");
> >             }else
> >                 System.err.println("tc at " + tcHome);
> >         }catch(java.lang.SecurityException err) {
> >             System.err.println("Security Exception"+ err);
> >         }catch(java.lang.NullPointerException err) {
> >             System.err.println("Property not set. Exception"+ err);
> >         }
> >
> > Any improvements please?
> >
> > Regards DaveP.
> >
> > **** snip here *****
> >
> > --
> > DISCLAIMER:
> >
> > NOTICE: The information contained in this email and any attachments is
> > confidential and may be privileged.  If you are not the intended
> > recipient you should not use, disclose, distribute or copy any of the
> > content of it or of any attachment; you are requested to notify the
> > sender immediately of your receipt of the email and then to delete it
> > and any attachments from your system.
> >
> > RNIB endeavours to ensure that emails and any attachments generated by
> > its staff are free from viruses or other contaminants.  However, it
> > cannot accept any responsibility for any  such which are transmitted.
> > We therefore recommend you scan all attachments.
> >
> > Please note that the statements and views expressed in this email and
> > any attachments are those of the author and do not necessarily represent
> > those of RNIB.
> >
> > RNIB Registered Charity Number: 226227
> >
> > Website: http://www.rnib.org.uk
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
> >
> 
> 
> --
> "You can't wake a person who is pretending to be asleep."
> 
> ~Native Proverb~
> 
> "Each man is good in His sight. It is not necessary for eagles to be crows."
> 
> ~Hunkesni (Sitting Bull), Hunkpapa Sioux~
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: File upload and download.

Posted by Dakota Jack <cr...@gmail.com>.
The following code gets you CATALINA_HOME.  I cannot tell if this will
be helpful to you or not.  Probably not, but what the heck, David.

Jack

  package com.whatever.classpath;

  import java.io.File;
  import java.net.URL;

  public final class Classpath {
    public static final String HERE  =  
Classpath.class.getClassLoader().getResource(
                                                             "com" +
File.separator +
                                                            
"whatever" + File.separator +
                                                            
"classpath" + File.separator +
                                                            
"Classpath.class").getFile();
    public static final String CATALINA_HOME = HERE.substring(
                                                                           1, 
                                                                      
    HERE.lastIndexOf("webapp"));
  }







On Wed, 17 Nov 2004 12:32:21 -0000, Pawson, David
<da...@rnib.org.uk> wrote:
> I'm using Tomcat 5.0.28.
> My app relates to upload and download.
> Using fileupload to upload files,
> and a basic file interface to store them
> to a fixed disk location.
> 
> Presenting a webpage with a list of links,
> the url needs to be within the tomcat installation
> (security etc).
> 
> Question.
>   How do people find out where the tomcat base
> install is, CATALINA_HOME?
> 
> My only solution so far is passing a property
> when tomcat is launched, and it does seem messy.
> 
>         try{
>             String tcHome = System.getProperty("tcHome");
>             if (tcHome==null || ){
>                 System.err.println("CATALINA_HOME not set");
>             }else
>                 System.err.println("tc at " + tcHome);
>         }catch(java.lang.SecurityException err) {
>             System.err.println("Security Exception"+ err);
>         }catch(java.lang.NullPointerException err) {
>             System.err.println("Property not set. Exception"+ err);
>         }
> 
> Any improvements please?
> 
> Regards DaveP.
> 
> **** snip here *****
> 
> --
> DISCLAIMER:
> 
> NOTICE: The information contained in this email and any attachments is
> confidential and may be privileged.  If you are not the intended
> recipient you should not use, disclose, distribute or copy any of the
> content of it or of any attachment; you are requested to notify the
> sender immediately of your receipt of the email and then to delete it
> and any attachments from your system.
> 
> RNIB endeavours to ensure that emails and any attachments generated by
> its staff are free from viruses or other contaminants.  However, it
> cannot accept any responsibility for any  such which are transmitted.
> We therefore recommend you scan all attachments.
> 
> Please note that the statements and views expressed in this email and
> any attachments are those of the author and do not necessarily represent
> those of RNIB.
> 
> RNIB Registered Charity Number: 226227
> 
> Website: http://www.rnib.org.uk
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


-- 
"You can't wake a person who is pretending to be asleep."

~Native Proverb~

"Each man is good in His sight. It is not necessary for eagles to be crows."

~Hunkesni (Sitting Bull), Hunkpapa Sioux~

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org