web.xml help - pulling images from the war under Apache

S

Scott Ellsworth

Hi, all.

I would like my webapp to pull images from the war/exploded deployment
directory, rather than having Apache try to snag them from the
filesystem. I have not figured out what to put in web.xml to make that
happen, and I have been experimenting, reading docs, and googling all
day. Anyone want to loan me a clue?

The webapp is to go under Tomcat 4.1.29/Apache 1.3.?. On both the
XServe and the Solaris machines that are going to be the hosts for this,
Apache is set to use mod_jk to forward requests to Tomcat.

When I tried the following web.xml, images appeared happily in if I
connected directly to Tomcat on port 9006. No images appeared if I
connected to Apache on port 80. The compiled jsps did appear.

<?xml version="1.0"?>
<!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>
<display-name>MyMonomer</display-name>
<description>mymonomer</description>
<servlet>
<servlet-name>mymonomer</servlet-name>
<jsp-file>/index.jsp</jsp-file>
</servlet>

<servlet-mapping>
<servlet-name>mymonomer</servlet-name>
<url-pattern>/*.gif</url-pattern>
</servlet-mapping>
</web-app>

I would have thought my url-pattern would have given me all gifs.

I tried the following servlet mapping, but no images were displayed even
in Tomcat on 9006.

<servlet-mapping>
<servlet-name>mymonomer</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

when I tried an url pattern of

<servlet-mapping>
<servlet-name>mymonomer</servlet-name>
<url-pattern>*</url-pattern>
</servlet-mapping>

Tomcat 4.1.29 started throwing exceptions.

NB: httpd.conf contains

<IfModule mod_jk.c>
JKWorkersFile /etc/httpd/workers.properties
JKLogFile /var/log/httpd/mod_jk.log
JKLogLevel error
JKMount /*.jsp JBoss1
JKMount /servlet/* JBoss1
JKMount /examples/* JBoss1
</IfModule>

in httpd.conf. jk.properties contains no content. server.xml contains
the usual defaults.

Scott
 
S

Scott Ellsworth

Scott Ellsworth said:
Hi, all.

I would like my webapp to pull images from the war/exploded deployment
directory, rather than having Apache try to snag them from the
filesystem. I have not figured out what to put in web.xml to make that
happen, and I have been experimenting, reading docs, and googling all
day. Anyone want to loan me a clue?

The webapp is to go under Tomcat 4.1.29/Apache 1.3.?. On both the
XServe and the Solaris machines that are going to be the hosts for this,
Apache is set to use mod_jk to forward requests to Tomcat.

When I tried the following web.xml, images appeared happily in if I
connected directly to Tomcat on port 9006. No images appeared if I
connected to Apache on port 80. The compiled jsps did appear.

<?xml version="1.0"?>
<!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>
<display-name>MyMonomer</display-name>
<description>mymonomer</description>
<servlet>
<servlet-name>mymonomer</servlet-name>
<jsp-file>/index.jsp</jsp-file>
</servlet>

<servlet-mapping>
<servlet-name>mymonomer</servlet-name>
<url-pattern>/*.gif</url-pattern>
</servlet-mapping>
</web-app>

Note: an example image that loads under Tomcat when referenced directly
on port 9006 might be:

http://test.mycompany.com:9006/mymonomer/images/btmLinks.gif

while one that fails might be:

http://test.mycompany.com/mymonomer/images/btmLinks.gif

The 404 page also seems to be apache generated, rather than Tomcat
generated. Is there more I must do to Tomcat/Apache? I would have
thought that installing the war via the manager would have set things up
such that localhost/mymonomer/foo would ask Tomcat for the foo resource.

Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top