You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by ha...@informatiefabriek.nl on 2003/04/16 10:35:33 UTC

Show files on filesystem

Hi all,

I have Tomcat 4.1 running on Linux.

I have installed Tomcat in /usr/java/jakarta-tomcat/

In my web application I would like to offer my user the possibilty to view 
PDF files stored elsewhere on the filesystem.
The PDF's are in /var/om/pdfs

In my web application I have a link the user can click. When he does so, a 
PDF should be downloaded or displayed in the browser.

How can I achieve this using only Tomcat?

In Apache httpd daemon I could use something like:

Alias /pdfs /var/om/pdfs

How do I achieve simular results using Tomcat?

Thanks,

Harm de Laat
Informatiefabriek


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


RE: Show files on filesystem

Posted by James Lewis <ja...@goodtechnology.com>.
The second option is certainly the most configurable, plus you will have the benefits of using all of the buffering input/output stream objects that the API provides.

james

> -----Original Message-----
> From: Andre E. Bar'yudin [mailto:baryudin@pob.huji.ac.il]
> Sent: 16 April 2003 10:06
> To: Tomcat Users List
> Subject: Re: Show files on filesystem
> 
> 
> On Срд, Апр 16, 2003 at 10:35:33 +0200, harm@informatiefabriek.nl wrote:
> > Hi all,
> > 
> > I have Tomcat 4.1 running on Linux.
> > 
> > I have installed Tomcat in /usr/java/jakarta-tomcat/
> > 
> > In my web application I would like to offer my user the 
> possibilty to view 
> > PDF files stored elsewhere on the filesystem.
> > The PDF's are in /var/om/pdfs
> > 
> > In my web application I have a link the user can click. When he 
> does so, a 
> > PDF should be downloaded or displayed in the browser.
> > 
> > How can I achieve this using only Tomcat?
> 
> The simpliest way is to make a link to your PDF files.  To the files
> themselves you may make a hard link, pointing somewhere under the Tomcat
> directory hierarchy.  To link directories, you'll have to use sybmolic
> links, which might require some configuration with newer versions of
> Tomcat. 
> 
> Another, more generic approach would be to use the standard Java IO API
> to read the file from its original location and then just write it out
> to the servlet's output stream.
> 
> Regards,
> 
> Andre.
> 
> -- 
> Andre E. Bar'yudin
> Phone: (972)-54-882-026       ICQ: 48036924
> Home page: http://www.cs.huji.ac.il/~baryudin/
> 
> 
> ---------------------------------------------------------------------
> 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: Show files on filesystem

Posted by Tim Funk <fu...@joedog.org>.
Add a header called Content-Disposition.
http://www.faqs.org/ftp/rfc/rfc2183.txt

-Tim

harm@informatiefabriek.nl wrote:
> My application now works. Users can click the link and Acrobat (in 
> installed) opens up the PDF file!
> But, when the user clicks the save button in acrobat they get: 
> show_pdf.pdf as filename. (This is the name of my action).
> How can I pass the original filename?
> 
> Thanks, Harm
> 
> 
> 
> 
> Tim Funk <fu...@joedog.org> 
> 04/16/2003 04:04 PM
> Please respond to
> "Tomcat Users List" <to...@jakarta.apache.org>
> 
> 
> To
> Tomcat Users List <to...@jakarta.apache.org>
> cc
> 
> Subject
> Re: Show files on filesystem
> 
> 
> 
> 
> 
> 
> That would be too easy :)
> 
> -Tim
> 
> harm@informatiefabriek.nl wrote:
> 
>>Thanks, that's a big help!
>>
>>Still I'm wondering. Would it not be more efficient to just provide a 
>>direct download link?
>>
>>Thanks,
>>
>>Harm.
>>
>>
>>
>>
>>Tim Funk <fu...@joedog.org> 
>>04/16/2003 03:52 PM
>>Please respond to
>>"Tomcat Users List" <to...@jakarta.apache.org>
>>
>>
>>To
>>Tomcat Users List <to...@jakarta.apache.org>
>>cc
>>
>>Subject
>>Re: Show files on filesystem
>>
>>
>>
>>
>>
>>
>>Actually that was a little inefficientbut was OK. You are not streaming 
>>the 
>>file as it is read. For efficiency, use a byte buffer to reduce the 
> 
> number 
> 
>>of 
>>function calls.
>>
>>  File f = new File(valueObj.getPath());
>>  InputStream is = new BufferedInputStream(new
>>  FileInputStream(valueObj.getPath()));
>>  OutputStream os = response.getOutputStream();
>>  response.setContentType("application/pdf");
>>
>>  byte[] buffer = new byte[1024]; /*or whatever size*/
>>
>>  int read = is.read(buffer);
>>  while (read >=0 ) {
>>     if (read>0)
>>         os.write(buffer,0, read);
>>     read = is.read(buffer);
>>  }
>>
>>/* NOT NEEDED  os.flush(); */
>>  is.close();
>>  os.close();
>>
>>-Tim
>>
>>harm@informatiefabriek.nl wrote:
>>
>>
>>>Hehe ;-)
>>>
>>>I know how java IO works... 
>>>I have coded the following:
>>>
>>>-----------------------
>>>File f = new File(valueObj.getPath());
>>>InputStream is = new BufferedInputStream(new 
>>>FileInputStream(valueObj.getPath()));
>>>OutputStream os = response.getOutputStream();
>>>response.setContentType("application/pdf");
>>>int b;
>>>while ((b = is.read()) != -1) {
>>>       os.write(b);
>>>}
>>>os.flush();
>>>os.close();
>>>is.close(); 
>>>----------------------------
>>>
>>>I'm just wondering if this method is efficient. Because the file first 
>>
>>has 
>>
>>
>>>to be read completely and then written to the output stream.
>>>
>>>Thanks,
>>>
>>>Harm.
>>>
>>
>>
>>
>>---------------------------------------------------------------------
>>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
> 
> 


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


Re: Show files on filesystem

Posted by ha...@informatiefabriek.nl.
My application now works. Users can click the link and Acrobat (in 
installed) opens up the PDF file!
But, when the user clicks the save button in acrobat they get: 
show_pdf.pdf as filename. (This is the name of my action).
How can I pass the original filename?

Thanks, Harm




Tim Funk <fu...@joedog.org> 
04/16/2003 04:04 PM
Please respond to
"Tomcat Users List" <to...@jakarta.apache.org>


To
Tomcat Users List <to...@jakarta.apache.org>
cc

Subject
Re: Show files on filesystem






That would be too easy :)

-Tim

harm@informatiefabriek.nl wrote:
> Thanks, that's a big help!
> 
> Still I'm wondering. Would it not be more efficient to just provide a 
> direct download link?
> 
> Thanks,
> 
> Harm.
> 
> 
> 
> 
> Tim Funk <fu...@joedog.org> 
> 04/16/2003 03:52 PM
> Please respond to
> "Tomcat Users List" <to...@jakarta.apache.org>
> 
> 
> To
> Tomcat Users List <to...@jakarta.apache.org>
> cc
> 
> Subject
> Re: Show files on filesystem
> 
> 
> 
> 
> 
> 
> Actually that was a little inefficientbut was OK. You are not streaming 
> the 
> file as it is read. For efficiency, use a byte buffer to reduce the 
number 
> of 
> function calls.
> 
>   File f = new File(valueObj.getPath());
>   InputStream is = new BufferedInputStream(new
>   FileInputStream(valueObj.getPath()));
>   OutputStream os = response.getOutputStream();
>   response.setContentType("application/pdf");
> 
>   byte[] buffer = new byte[1024]; /*or whatever size*/
> 
>   int read = is.read(buffer);
>   while (read >=0 ) {
>      if (read>0)
>          os.write(buffer,0, read);
>      read = is.read(buffer);
>   }
> 
> /* NOT NEEDED  os.flush(); */
>   is.close();
>   os.close();
> 
> -Tim
> 
> harm@informatiefabriek.nl wrote:
> 
>>Hehe ;-)
>>
>>I know how java IO works... 
>>I have coded the following:
>>
>>-----------------------
>>File f = new File(valueObj.getPath());
>>InputStream is = new BufferedInputStream(new 
>>FileInputStream(valueObj.getPath()));
>>OutputStream os = response.getOutputStream();
>>response.setContentType("application/pdf");
>>int b;
>>while ((b = is.read()) != -1) {
>>        os.write(b);
>>}
>>os.flush();
>>os.close();
>>is.close(); 
>>----------------------------
>>
>>I'm just wondering if this method is efficient. Because the file first 
> 
> has 
> 
>>to be read completely and then written to the output stream.
>>
>>Thanks,
>>
>>Harm.
>>
> 
> 
> 
> ---------------------------------------------------------------------
> 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: Show files on filesystem

Posted by Tim Funk <fu...@joedog.org>.
That would be too easy :)

-Tim

harm@informatiefabriek.nl wrote:
> Thanks, that's a big help!
> 
> Still I'm wondering. Would it not be more efficient to just provide a 
> direct download link?
> 
> Thanks,
> 
> Harm.
> 
> 
> 
> 
> Tim Funk <fu...@joedog.org> 
> 04/16/2003 03:52 PM
> Please respond to
> "Tomcat Users List" <to...@jakarta.apache.org>
> 
> 
> To
> Tomcat Users List <to...@jakarta.apache.org>
> cc
> 
> Subject
> Re: Show files on filesystem
> 
> 
> 
> 
> 
> 
> Actually that was a little inefficientbut was OK. You are not streaming 
> the 
> file as it is read. For efficiency, use a byte buffer to reduce the number 
> of 
> function calls.
> 
>   File f = new File(valueObj.getPath());
>   InputStream is = new BufferedInputStream(new
>   FileInputStream(valueObj.getPath()));
>   OutputStream os = response.getOutputStream();
>   response.setContentType("application/pdf");
> 
>   byte[] buffer = new byte[1024]; /*or whatever size*/
> 
>   int read = is.read(buffer);
>   while (read >=0 ) {
>      if (read>0)
>          os.write(buffer,0, read);
>      read = is.read(buffer);
>   }
> 
> /* NOT NEEDED  os.flush(); */
>   is.close();
>   os.close();
> 
> -Tim
> 
> harm@informatiefabriek.nl wrote:
> 
>>Hehe ;-)
>>
>>I know how java IO works... 
>>I have coded the following:
>>
>>-----------------------
>>File f = new File(valueObj.getPath());
>>InputStream is = new BufferedInputStream(new 
>>FileInputStream(valueObj.getPath()));
>>OutputStream os = response.getOutputStream();
>>response.setContentType("application/pdf");
>>int b;
>>while ((b = is.read()) != -1) {
>>        os.write(b);
>>}
>>os.flush();
>>os.close();
>>is.close(); 
>>----------------------------
>>
>>I'm just wondering if this method is efficient. Because the file first 
> 
> has 
> 
>>to be read completely and then written to the output stream.
>>
>>Thanks,
>>
>>Harm.
>>
> 
> 
> 
> ---------------------------------------------------------------------
> 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: Show files on filesystem

Posted by ha...@informatiefabriek.nl.
Thanks, that's a big help!

Still I'm wondering. Would it not be more efficient to just provide a 
direct download link?

Thanks,

Harm.




Tim Funk <fu...@joedog.org> 
04/16/2003 03:52 PM
Please respond to
"Tomcat Users List" <to...@jakarta.apache.org>


To
Tomcat Users List <to...@jakarta.apache.org>
cc

Subject
Re: Show files on filesystem






Actually that was a little inefficientbut was OK. You are not streaming 
the 
file as it is read. For efficiency, use a byte buffer to reduce the number 
of 
function calls.

  File f = new File(valueObj.getPath());
  InputStream is = new BufferedInputStream(new
  FileInputStream(valueObj.getPath()));
  OutputStream os = response.getOutputStream();
  response.setContentType("application/pdf");

  byte[] buffer = new byte[1024]; /*or whatever size*/

  int read = is.read(buffer);
  while (read >=0 ) {
     if (read>0)
         os.write(buffer,0, read);
     read = is.read(buffer);
  }

/* NOT NEEDED  os.flush(); */
  is.close();
  os.close();

-Tim

harm@informatiefabriek.nl wrote:
> Hehe ;-)
> 
> I know how java IO works... 
> I have coded the following:
> 
> -----------------------
> File f = new File(valueObj.getPath());
> InputStream is = new BufferedInputStream(new 
> FileInputStream(valueObj.getPath()));
> OutputStream os = response.getOutputStream();
> response.setContentType("application/pdf");
> int b;
> while ((b = is.read()) != -1) {
>         os.write(b);
> }
> os.flush();
> os.close();
> is.close(); 
> ----------------------------
> 
> I'm just wondering if this method is efficient. Because the file first 
has 
> to be read completely and then written to the output stream.
> 
> Thanks,
> 
> Harm.
> 


---------------------------------------------------------------------
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: Show files on filesystem

Posted by Tim Funk <fu...@joedog.org>.
Actually that was a little inefficientbut was OK. You are not streaming the 
file as it is read. For efficiency, use a byte buffer to reduce the number of 
function calls.

  File f = new File(valueObj.getPath());
  InputStream is = new BufferedInputStream(new
  FileInputStream(valueObj.getPath()));
  OutputStream os = response.getOutputStream();
  response.setContentType("application/pdf");

  byte[] buffer = new byte[1024]; /*or whatever size*/

  int read = is.read(buffer);
  while (read >=0 ) {
     if (read>0)
         os.write(buffer,0, read);
     read = is.read(buffer);
  }

/* NOT NEEDED  os.flush(); */
  is.close();
  os.close();

-Tim

harm@informatiefabriek.nl wrote:
> Hehe ;-)
> 
> I know how java IO works... 
> I have coded the following:
> 
> -----------------------
> File f = new File(valueObj.getPath());
> InputStream is = new BufferedInputStream(new 
> FileInputStream(valueObj.getPath()));
> OutputStream os = response.getOutputStream();
> response.setContentType("application/pdf");
> int b;
> while ((b = is.read()) != -1) {
>         os.write(b);
> }
> os.flush();
> os.close();
> is.close(); 
> ----------------------------
> 
> I'm just wondering if this method is efficient. Because the file first has 
> to be read completely and then written to the output stream.
> 
> Thanks,
> 
> Harm.
> 


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


RE: Show files on filesystem

Posted by ha...@informatiefabriek.nl.
Hehe ;-)

I know how java IO works... 
I have coded the following:

-----------------------
File f = new File(valueObj.getPath());
InputStream is = new BufferedInputStream(new 
FileInputStream(valueObj.getPath()));
OutputStream os = response.getOutputStream();
response.setContentType("application/pdf");
int b;
while ((b = is.read()) != -1) {
        os.write(b);
}
os.flush();
os.close();
is.close(); 
----------------------------

I'm just wondering if this method is efficient. Because the file first has 
to be read completely and then written to the output stream.

Thanks,

Harm.




"James Lewis" <ja...@goodtechnology.com> 
04/16/2003 03:20 PM
Please respond to
"Tomcat Users List" <to...@jakarta.apache.org>


To
"Tomcat Users List" <to...@jakarta.apache.org>
cc

Subject
RE: Show files on filesystem






yes :p

Umm, you cold have a look at the API javadocs for io classes, or
alternatively the tutorial on the sun site is pretty good.

http://java.sun.com/docs/books/tutorial/essential/io/index.html (for a 
java
IO tutorial)

and:

http://java.sun.com/products/servlet/2.2/javadoc/ for the
ServletOutputStream doc

All fairly straightforward.

james






> -----Original Message-----
> From: harm@informatiefabriek.nl [mailto:harm@informatiefabriek.nl]
> Sent: 16 April 2003 14:08
> To: Tomcat Users List
> Subject: Re: Show files on filesystem
>
>
> Thanks for your reply....
>
> I think I should go with the second option. Do have an example on how to
> do this?
>
> Thanks,
>
> Harm.
>
>
>
>
> "Andre E. Bar'yudin" <ba...@pob.huji.ac.il>
> 04/16/2003 11:06 AM
> Please respond to
> "Tomcat Users List" <to...@jakarta.apache.org>
>
>
> To
> Tomcat Users List <to...@jakarta.apache.org>
> cc
>
> Subject
> Re: Show files on filesystem
>
>
>
>
>
>
> On Срд, Апр 16, 2003 at 10:35:33 +0200, harm@informatiefabriek.nl wrote:
> > Hi all,
> >
> > I have Tomcat 4.1 running on Linux.
> >
> > I have installed Tomcat in /usr/java/jakarta-tomcat/
> >
> > In my web application I would like to offer my user the possibilty to
> view
> > PDF files stored elsewhere on the filesystem.
> > The PDF's are in /var/om/pdfs
> >
> > In my web application I have a link the user can click. When he
> does so,
> a
> > PDF should be downloaded or displayed in the browser.
> >
> > How can I achieve this using only Tomcat?
>
> The simpliest way is to make a link to your PDF files.  To the files
> themselves you may make a hard link, pointing somewhere under the Tomcat
> directory hierarchy.  To link directories, you'll have to use sybmolic
> links, which might require some configuration with newer versions of
> Tomcat.
>
> Another, more generic approach would be to use the standard Java IO API
> to read the file from its original location and then just write it out
> to the servlet's output stream.
>
> Regards,
>
> Andre.
>
> --
> Andre E. Bar'yudin
> Phone: (972)-54-882-026       ICQ: 48036924
> Home page: http://www.cs.huji.ac.il/~baryudin/
>
>
> ---------------------------------------------------------------------
> 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: Show files on filesystem

Posted by James Lewis <ja...@goodtechnology.com>.
yes :p

Umm, you cold have a look at the API javadocs for io classes, or
alternatively the tutorial on the sun site is pretty good.

http://java.sun.com/docs/books/tutorial/essential/io/index.html (for a java
IO tutorial)

and:

http://java.sun.com/products/servlet/2.2/javadoc/ for the
ServletOutputStream doc

All fairly straightforward.

james






> -----Original Message-----
> From: harm@informatiefabriek.nl [mailto:harm@informatiefabriek.nl]
> Sent: 16 April 2003 14:08
> To: Tomcat Users List
> Subject: Re: Show files on filesystem
>
>
> Thanks for your reply....
>
> I think I should go with the second option. Do have an example on how to
> do this?
>
> Thanks,
>
> Harm.
>
>
>
>
> "Andre E. Bar'yudin" <ba...@pob.huji.ac.il>
> 04/16/2003 11:06 AM
> Please respond to
> "Tomcat Users List" <to...@jakarta.apache.org>
>
>
> To
> Tomcat Users List <to...@jakarta.apache.org>
> cc
>
> Subject
> Re: Show files on filesystem
>
>
>
>
>
>
> On Срд, Апр 16, 2003 at 10:35:33 +0200, harm@informatiefabriek.nl wrote:
> > Hi all,
> >
> > I have Tomcat 4.1 running on Linux.
> >
> > I have installed Tomcat in /usr/java/jakarta-tomcat/
> >
> > In my web application I would like to offer my user the possibilty to
> view
> > PDF files stored elsewhere on the filesystem.
> > The PDF's are in /var/om/pdfs
> >
> > In my web application I have a link the user can click. When he
> does so,
> a
> > PDF should be downloaded or displayed in the browser.
> >
> > How can I achieve this using only Tomcat?
>
> The simpliest way is to make a link to your PDF files.  To the files
> themselves you may make a hard link, pointing somewhere under the Tomcat
> directory hierarchy.  To link directories, you'll have to use sybmolic
> links, which might require some configuration with newer versions of
> Tomcat.
>
> Another, more generic approach would be to use the standard Java IO API
> to read the file from its original location and then just write it out
> to the servlet's output stream.
>
> Regards,
>
> Andre.
>
> --
> Andre E. Bar'yudin
> Phone: (972)-54-882-026       ICQ: 48036924
> Home page: http://www.cs.huji.ac.il/~baryudin/
>
>
> ---------------------------------------------------------------------
> 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: Show files on filesystem

Posted by ha...@informatiefabriek.nl.
Thanks for your reply....

I think I should go with the second option. Do have an example on how to 
do this?

Thanks,

Harm.




"Andre E. Bar'yudin" <ba...@pob.huji.ac.il> 
04/16/2003 11:06 AM
Please respond to
"Tomcat Users List" <to...@jakarta.apache.org>


To
Tomcat Users List <to...@jakarta.apache.org>
cc

Subject
Re: Show files on filesystem






On Срд, Апр 16, 2003 at 10:35:33 +0200, harm@informatiefabriek.nl wrote:
> Hi all,
> 
> I have Tomcat 4.1 running on Linux.
> 
> I have installed Tomcat in /usr/java/jakarta-tomcat/
> 
> In my web application I would like to offer my user the possibilty to 
view 
> PDF files stored elsewhere on the filesystem.
> The PDF's are in /var/om/pdfs
> 
> In my web application I have a link the user can click. When he does so, 
a 
> PDF should be downloaded or displayed in the browser.
> 
> How can I achieve this using only Tomcat?

The simpliest way is to make a link to your PDF files.  To the files
themselves you may make a hard link, pointing somewhere under the Tomcat
directory hierarchy.  To link directories, you'll have to use sybmolic
links, which might require some configuration with newer versions of
Tomcat. 

Another, more generic approach would be to use the standard Java IO API
to read the file from its original location and then just write it out
to the servlet's output stream.

Regards,

Andre.

-- 
Andre E. Bar'yudin
Phone: (972)-54-882-026       ICQ: 48036924
Home page: http://www.cs.huji.ac.il/~baryudin/


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




Re: Show files on filesystem

Posted by "Andre E. Bar'yudin" <ba...@pob.huji.ac.il>.
On Срд, Апр 16, 2003 at 10:35:33 +0200, harm@informatiefabriek.nl wrote:
> Hi all,
> 
> I have Tomcat 4.1 running on Linux.
> 
> I have installed Tomcat in /usr/java/jakarta-tomcat/
> 
> In my web application I would like to offer my user the possibilty to view 
> PDF files stored elsewhere on the filesystem.
> The PDF's are in /var/om/pdfs
> 
> In my web application I have a link the user can click. When he does so, a 
> PDF should be downloaded or displayed in the browser.
> 
> How can I achieve this using only Tomcat?

The simpliest way is to make a link to your PDF files.  To the files
themselves you may make a hard link, pointing somewhere under the Tomcat
directory hierarchy.  To link directories, you'll have to use sybmolic
links, which might require some configuration with newer versions of
Tomcat. 

Another, more generic approach would be to use the standard Java IO API
to read the file from its original location and then just write it out
to the servlet's output stream.

Regards,

Andre.

-- 
Andre E. Bar'yudin
Phone: (972)-54-882-026       ICQ: 48036924
Home page: http://www.cs.huji.ac.il/~baryudin/


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