| Author |
Unable To load image in JSP file
|
Subbarao Kondabala
Greenhorn
Joined: May 17, 2005
Posts: 26
|
|
Hi, I had written code in my JSP file as follows <img src="/images/fish.gif"> The above code worked in websphere, but when I keep the same JSP file in tomcat5.0, I am unable to see the image. For dispalying image in tomcat I need to do the following change. <img src="images/fish.gif"> If I remove / before images then the code got worked. I need the same code should work in tomcat also without doing modifications. Can any one please help regarding this. Thanks in advance Subbarao [ April 16, 2007: Message edited by: Bear Bibeault ]
|
Thanks and Regards,
Subbarao Kondabala
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Preceding a relative URL with a slash in a Java web app will only work if your app is the ROOT app on the server. If it is anything else you are skipping the contextPath. The best way to build links is to make them relative to the root of the application by reading the contextPath from the request object: Example: Or, for pre JSP2.0 containers [ April 16, 2007: Message edited by: Ben Souther ]
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Subbarao Kondabala
Greenhorn
Joined: May 17, 2005
Posts: 26
|
|
Thanks Ben. I heard like if we change sever.xml by writing <contex> tag we can directly use code of websphere in Tomcat. If you know can you please let me know with example Thanks and Regards, Subbarao Kondabala
|
 |
 |
|
|
subject: Unable To load image in JSP file
|
|
|