*
The moose likes Tomcat and the fly likes Loading a text doc into a browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Loading a text doc into a browser" Watch "Loading a text doc into a browser" New topic
Author

Loading a text doc into a browser

Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 573
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

Joined: Mar 22, 2000
Posts: 12760
    
    5
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

Joined: Jun 29, 2002
Posts: 573
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

Joined: Jun 29, 2002
Posts: 573
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

Joined: Jun 29, 2002
Posts: 573
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
 
 
subject: Loading a text doc into a browser
 
Similar Threads
Weblogic error messages/logs
JDK and Browser
Struts issue
JDK and Browser
If Servlet load-on-startup, Does it also need servlet-mapping?