• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Loading a text doc into a browser

 
Tony Evans
Ranch Hand
Posts: 598
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a application that loads text docs into the following directory:
C:\jakarta-tomcat-5.0.19\webapps\documentHolder.

What I want to do is open those documents via my web browser: I have no idea how to map a URL to that location.

Do i have to create a mapping similar to the mapping of a servlet in the
web.xml file.

Thanks for any help.

Tony
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In order for Tomcat to consider your webapps/documentHolder directory to be part of a web application, it has to see a documentHolder/WEB-INF directory with a minimum web.xml file in it. As I recall, you can copy one of the existing web.xml and take out everything between the
<web-app>
</web-app>
to create a minimum web.xml
Bill
 
Tony Evans
Ranch Hand
Posts: 598
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi William,

Thanks for the advice, but I still cant get it to work.

What I have so far is a directory and test file:
C:\jakarta-tomcat-4.1.12\webapps\know_your_customer_docs\customer1\customer1Doc.doc.

The link
http://localhost:8080/customers/know_your_customer_docs/customer1/customer1Doc.doc.

should load the
 
Tony Evans
Ranch Hand
Posts: 598
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi William,

Thanks for the advice, but I still cant get it to work.

What I have so far is a directory and test file:
C:\jakarta-tomcat-4.1.12\webapps\know_your_customer_docs\customer1\customer1Doc.doc.

The link
http://localhost:8080/customers/know_your_customer_docs/
customer1/customer1Doc.doc

should load the doc into the browser:

I though you could set the path in the server.xml so I added the following code to the server.xml

<Context path="/customers"
docBase="../server/webapps/know_your_customer_docs" debug="0" reloadable="false"
</Context>

I copied this code from an example and I think it sets the path URL path to the absolute path doc path.

I also did what you suggested and added a WEB-INF folder under my know_your_customer_docs with a minimum web.xml doc.

I am not sure what should go in the web.xml doc apart from

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
</web-app>

Thanks for any help Tony.
 
Tony Evans
Ranch Hand
Posts: 598
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hve fixed the problem, I have removed the context set up and replaced the link The link
http://localhost:8080/customers/customer1/customer1Doc.doc


with
The link
http://localhost:8080/know_your_customer_docs/customer1/customer1Doc.doc

And it works

Tony
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic