You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Lee Peik Feng <pf...@syabas.com> on 2003/06/25 12:50:17 UTC

refering files in other directory from one webapps

Hi,
    I have set a webapp like below:
    <Context path="/music" docBase="C:/My Music" debug="0"/>

    I have mp3 files in C:/My Music and I can reach the mp3 files like this:
    http://<ip>:8080/music/test.mp3
    and browser will play the song (with Win Media Player)

    is it posible that I use same webapps http://<ip>:8080/music/
    and play mp3 files in other directory?

    I have written a JSP that stream the mp3 files as below and it works,
    but is it possible that Tomcat can refer to the mp3 files in other
directory directly?
    or any other ways?


<%
 String filename = "C:\\my.mp3";

  File file = new File(filename);

  ReadableByteChannel rbc = Channels.newChannel(new FileInputStream(file));
  WritableByteChannel wbc = Channels.newChannel(response.getOutputStream());

   response.setContentType("audio/mpeg");
   response.setContentLength((int)file.length());
   response.setHeader("Content-Disposition", "attachment;
filename="+filename.substring(filename.lastIndexOf(File.separator)+1)+";");

   ByteBuffer bb = ByteBuffer.allocateDirect(1024);
   while (rbc.read(bb) != -1)
   {
    bb.flip();
    wbc.write(bb);
    bb.clear();
   }

   wbc.close();
   rbc.close();
%>




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


Re: Logging the correct time

Posted by Mike Hulse <mh...@rmcisdc3.rmc.com>.
Thanks, but for some reason, due to some unknown wisdom at corporate
headquarters,
they have blocked that url.

----- Original Message -----
From: "Jason Bainbridge" <ja...@jblinux.org>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Wednesday, June 25, 2003 8:02 AM
Subject: Re: Logging the correct time


> On Wed, 25 Jun 2003 19:39, Mike Hulse wrote:
> > I was afraid someone would ask what platform.  :)  I am using an IBM
AS400.
> > The universal time offset is -4:00 hours. Which is EDT.  Apache is
> > recording time in its logs correctly.  Tomcat 4.1.24 stand-alone logs
are
> > the only place that
> > that the time is not correct.
>
> See this new post for some tips on how to fix the problem:
>
> http://tinyurl.com/f7s0
>
> --
> Jason Bainbridge
> http://jblinux.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>



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


Re: Logging the correct time

Posted by Jason Bainbridge <ja...@jblinux.org>.
On Wed, 25 Jun 2003 19:39, Mike Hulse wrote:
> I was afraid someone would ask what platform.  :)  I am using an IBM AS400.
> The universal time offset is -4:00 hours. Which is EDT.  Apache is
> recording time in its logs correctly.  Tomcat 4.1.24 stand-alone logs are
> the only place that
> that the time is not correct.

See this new post for some tips on how to fix the problem:

http://tinyurl.com/f7s0

-- 
Jason Bainbridge
http://jblinux.org

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


Re: Logging the correct time

Posted by Mike Hulse <mh...@rmcisdc3.rmc.com>.
Well that did the trick.  There was tons of information generated by that
jsp.
The system thought "user.timezone=CENTRAL", so I added user.timezone
to a SystemDefault.properties file and set it to EST.  Everything is fine
now
and it is adjusted to daylight time.

Thanks,
Mike

----- Original Message -----
From: "Tim Funk" <fu...@joedog.org>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Wednesday, June 25, 2003 8:00 AM
Subject: Re: Logging the correct time


> Doh! IIRC, the AS400 reads different properties files to load system
> properties. Also - what happens with this jsp:
> <%
> for(java.util.Enumeration e =
> System.getProperties().propertyNames();e.hasMoreElements() ;){
>     Object x = e.nextElement();
>     out.println(x + "=" + System.getProperty(x.toString()));
> }
> %>
>
> See if a System property user.timezone is filled in or the AS400 JVM might
> use a different one.
>
> -Tim
>
> Mike Hulse wrote:
> > I was afraid someone would ask what platform.  :)  I am using an IBM
AS400.
> > The universal time offset is -4:00 hours. Which is EDT.  Apache is
recording
> > time in its logs correctly.  Tomcat 4.1.24 stand-alone logs are the only
> > place that
> > that the time is not correct.
> >
> > ----- Original Message -----
> > From: "Jason Bainbridge" <ja...@jblinux.org>
> > To: "Tomcat Users List" <to...@jakarta.apache.org>
> > Sent: Wednesday, June 25, 2003 7:18 AM
> > Subject: Re: Logging the correct time
> >
> >
> >
> >>On Wed, 25 Jun 2003 19:04, Mike Hulse wrote:
> >>
> >>>Hi,
> >>>
> >>>Where do I set/adjust the time that is recorded in the log files?
> >>>Everything is 6 hours off.  I am in EDT (USA Eastern Daylight time)
> >>>and it looks like everything is CDT (Central European Daylight time).
> >>
> >>Are you using Windows 2000 with SP3 installed by any chance? MS does
some
> >>funny business with the installation of SP3 that stuffs up the timezone
> >>settings for the JRE. Try changing to a different timezone in windows,
> >
> > then
> >
> >>switch back to the correct one and restart Tomcat.
> >>
> >>If you are using a different environment please post details.
> >>
> >>Regards,
> >>--
> >>Jason Bainbridge
> >>http://jblinux.org
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >>
> >>
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>



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


Re: Logging the correct time

Posted by Tim Funk <fu...@joedog.org>.
Doh! IIRC, the AS400 reads different properties files to load system 
properties. Also - what happens with this jsp:
<%
for(java.util.Enumeration e = 
System.getProperties().propertyNames();e.hasMoreElements() ;){
    Object x = e.nextElement();
    out.println(x + "=" + System.getProperty(x.toString()));
}
%>

See if a System property user.timezone is filled in or the AS400 JVM might 
use a different one.

-Tim

Mike Hulse wrote:
> I was afraid someone would ask what platform.  :)  I am using an IBM AS400.
> The universal time offset is -4:00 hours. Which is EDT.  Apache is recording
> time in its logs correctly.  Tomcat 4.1.24 stand-alone logs are the only
> place that
> that the time is not correct.
> 
> ----- Original Message -----
> From: "Jason Bainbridge" <ja...@jblinux.org>
> To: "Tomcat Users List" <to...@jakarta.apache.org>
> Sent: Wednesday, June 25, 2003 7:18 AM
> Subject: Re: Logging the correct time
> 
> 
> 
>>On Wed, 25 Jun 2003 19:04, Mike Hulse wrote:
>>
>>>Hi,
>>>
>>>Where do I set/adjust the time that is recorded in the log files?
>>>Everything is 6 hours off.  I am in EDT (USA Eastern Daylight time)
>>>and it looks like everything is CDT (Central European Daylight time).
>>
>>Are you using Windows 2000 with SP3 installed by any chance? MS does some
>>funny business with the installation of SP3 that stuffs up the timezone
>>settings for the JRE. Try changing to a different timezone in windows,
> 
> then
> 
>>switch back to the correct one and restart Tomcat.
>>
>>If you are using a different environment please post details.
>>
>>Regards,
>>--
>>Jason Bainbridge
>>http://jblinux.org
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>>
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 


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


Re: Logging the correct time

Posted by Mike Hulse <mh...@rmcisdc3.rmc.com>.
I was afraid someone would ask what platform.  :)  I am using an IBM AS400.
The universal time offset is -4:00 hours. Which is EDT.  Apache is recording
time in its logs correctly.  Tomcat 4.1.24 stand-alone logs are the only
place that
that the time is not correct.

----- Original Message -----
From: "Jason Bainbridge" <ja...@jblinux.org>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Wednesday, June 25, 2003 7:18 AM
Subject: Re: Logging the correct time


> On Wed, 25 Jun 2003 19:04, Mike Hulse wrote:
> > Hi,
> >
> > Where do I set/adjust the time that is recorded in the log files?
> > Everything is 6 hours off.  I am in EDT (USA Eastern Daylight time)
> > and it looks like everything is CDT (Central European Daylight time).
>
> Are you using Windows 2000 with SP3 installed by any chance? MS does some
> funny business with the installation of SP3 that stuffs up the timezone
> settings for the JRE. Try changing to a different timezone in windows,
then
> switch back to the correct one and restart Tomcat.
>
> If you are using a different environment please post details.
>
> Regards,
> --
> Jason Bainbridge
> http://jblinux.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>



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


Re: Logging the correct time

Posted by Jason Bainbridge <ja...@jblinux.org>.
On Wed, 25 Jun 2003 19:04, Mike Hulse wrote:
> Hi,
>
> Where do I set/adjust the time that is recorded in the log files?
> Everything is 6 hours off.  I am in EDT (USA Eastern Daylight time)
> and it looks like everything is CDT (Central European Daylight time).

Are you using Windows 2000 with SP3 installed by any chance? MS does some 
funny business with the installation of SP3 that stuffs up the timezone 
settings for the JRE. Try changing to a different timezone in windows, then 
switch back to the correct one and restart Tomcat.

If you are using a different environment please post details.

Regards,
-- 
Jason Bainbridge
http://jblinux.org

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


Re: Logging the correct time

Posted by Mike Hulse <mh...@rmcisdc3.rmc.com>.
Sorry about the blank post.

All times in Apache and the server are correct.  Only Tomcat 4.1.24
stand-alone are not.

----- Original Message -----
From: "Mike Hulse" <mh...@rmcisdc3.rmc.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Wednesday, June 25, 2003 7:40 AM
Subject: Re: Logging the correct time


>
> ----- Original Message -----
> From: "Tim Funk" <fu...@joedog.org>
> To: "Tomcat Users List" <to...@jakarta.apache.org>
> Sent: Wednesday, June 25, 2003 7:32 AM
> Subject: Re: Logging the correct time
>
>
> > Which component? In the meantime check the following:
> > - The computer's OS time
> > - The computer's OS timezone
> > - Is GMT time actually being logged instead?
> > - Are wacky JVM args being passed to tomcat to trick it into thinking
your
> in
> > a different timezone?
> > - If on unix - Before startup of tomcat -is the useris setting
environment
> > variables which affect timezone?
> >
> > -Tim
> >
> >
> > Mike Hulse wrote:
> > > Hi,
> > >
> > > Where do I set/adjust the time that is recorded in the log files?
> > > Everything is 6 hours off.  I am in EDT (USA Eastern Daylight time)
> > > and it looks like everything is CDT (Central European Daylight time).
> > >
> > > Thanks,
> > > Mike
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>



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


Re: Logging the correct time

Posted by Mike Hulse <mh...@rmcisdc3.rmc.com>.
----- Original Message -----
From: "Tim Funk" <fu...@joedog.org>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Wednesday, June 25, 2003 7:32 AM
Subject: Re: Logging the correct time


> Which component? In the meantime check the following:
> - The computer's OS time
> - The computer's OS timezone
> - Is GMT time actually being logged instead?
> - Are wacky JVM args being passed to tomcat to trick it into thinking your
in
> a different timezone?
> - If on unix - Before startup of tomcat -is the useris setting environment
> variables which affect timezone?
>
> -Tim
>
>
> Mike Hulse wrote:
> > Hi,
> >
> > Where do I set/adjust the time that is recorded in the log files?
> > Everything is 6 hours off.  I am in EDT (USA Eastern Daylight time)
> > and it looks like everything is CDT (Central European Daylight time).
> >
> > Thanks,
> > Mike
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>



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


Re: Logging the correct time

Posted by Tim Funk <fu...@joedog.org>.
Which component? In the meantime check the following:
- The computer's OS time
- The computer's OS timezone
- Is GMT time actually being logged instead?
- Are wacky JVM args being passed to tomcat to trick it into thinking your in 
a different timezone?
- If on unix - Before startup of tomcat -is the useris setting environment 
variables which affect timezone?

-Tim


Mike Hulse wrote:
> Hi,
> 
> Where do I set/adjust the time that is recorded in the log files?
> Everything is 6 hours off.  I am in EDT (USA Eastern Daylight time)
> and it looks like everything is CDT (Central European Daylight time).
> 
> Thanks,
> Mike
> 
>  


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


Logging the correct time

Posted by Mike Hulse <mh...@rmcisdc3.rmc.com>.
Hi,

Where do I set/adjust the time that is recorded in the log files?
Everything is 6 hours off.  I am in EDT (USA Eastern Daylight time)
and it looks like everything is CDT (Central European Daylight time).

Thanks,
Mike



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