| Author |
WAR Deployment - Images not loading
|
Gokul Ram
Greenhorn
Joined: Mar 18, 2005
Posts: 5
|
|
Hi, I've developed a web appln which is being deployed in Sun One App Server 7. And while deploying I gave the context-root as /Test and I'm invoking the login jsp page using a Controller servlet. The issue is the images are not loading when the page loads. Should there be any entry be made in the web.xml for images alone ? below is the entry from the server.xml. <applications dynamic-reload-enabled="false" dynamic-reload-poll-interval-in-seconds="2"> <web-module enabled="true" location="C:\Sun9\jstudio\AppServer7\domains\domain1\server2\applications\j2ee-modules\project_2" name="project" context-root="/Test"/> </applications> Can anybody pls help ? I'm stuck... Thanks, -GR
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
|
Post one of your HTML Image tags.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Gokul Ram
Greenhorn
Joined: Mar 18, 2005
Posts: 5
|
|
hi, this is from the jsp... <img src="abc_seal.gif"> p.s: All requests go to the servlet and they get redirected from there.. so the initial login page is also called thru the servlet by passing a init-param as 'LOGIN'... below is the web.xml entry... <?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> <servlet> <servlet-name>Controller</servlet-name> <servlet-class>com.hud.gims.controller.Controller</servlet-class> <init-param> <param-name>event</param-name> <param-value>LOGIN</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>Controller</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Controller</servlet-name> <url-pattern>/*.jsp</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Controller</servlet-name> <url-pattern>/*.html</url-pattern> </servlet-mapping> </web-app> Thanks....
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
All request are going to your controller servlet. <url-pattern>/</url-pattern>
|
 |
Gokul Ram
Greenhorn
Joined: Mar 18, 2005
Posts: 5
|
|
Yes Ben. Thats where the problem I'm facing now. I'm not sure how to point to the images. Can you pls help me in fixing this ? any suggestions..
|
 |
Gokul Ram
Greenhorn
Joined: Mar 18, 2005
Posts: 5
|
|
hi Ben.. any suggestions... i'm stuck.. i tried different possibilities in the web.xml.. but no luck... can anybody pls help me out ?
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12271
|
|
Does the controller ever see the image requests? What is it supposed to do when it gets one? Bill
|
 |
Gokul Ram
Greenhorn
Joined: Mar 18, 2005
Posts: 5
|
|
Thanks for the reply... Actually the controller doesnt do anything for the images. It just forwards the request to other JavaBeans, Database access objects.. I'm just calling the images in the jsp's as, <img src="hud_seal.gif"> This is where it is not able to resolve the path... From all the jsp's the request goes to the controller... and it processes.. Hope I was able to explain... Pls let me know if you have any suggestions...
|
 |
todd runstein
Ranch Hand
Joined: Feb 15, 2005
Posts: 64
|
|
|
Is the image in the same directory as your jsp file?
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Thanks for the reply... Actually the controller doesnt do anything for the images. It just forwards the request to other JavaBeans, Database access objects.. I'm just calling the images in the jsp's as, <img src="hud_seal.gif">
If you're going to have your controller servlet intercept ALL requests than you are going to have to write your own code to stream the images. This isn't difficult. If you want an example look at http://simple.souther.us/SimpleStream.war. I would argue, however, that if your app isn't about streaming images, and you're not adding any functionality, other than what the default servlet would do, don't intercept all requests with your controller.
|
 |
 |
|
|
subject: WAR Deployment - Images not loading
|
|
|