aspose file tools*
The moose likes Servlets and the fly likes Deployment issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Deployment issue" Watch "Deployment issue" New topic
Author

Deployment issue

Hari babu
Ranch Hand

Joined: Jun 25, 2001
Posts: 208
Below is my Web application structure ( i have shown the only the required files/ folders). Myapp,images,WEB-INF are at same level
web
Myapp
start.jsp
images
logo.gif
WEB-INF
web.xml

my start.jsp looks like this, where iam trying to display the logo image from images folder
<%
// do nothing other than showing the image
%>
<html>
<head></head>
<body>
<img src="/images/logo.gif">
</body>
</html>

The above start.jsp displays the image when i deploy this application as default ( i access it as http://localhost/). The image path ( when i check thru Image properties in IE ) will be http://localhost/images/logo.gif. But the problem comes when i give a name to the web application, say i give it as "mywebapplication" ( i access it as http://localhost/myapplication), In the case the image wont be shown. Still its path will be http://localhost/images/logo.gif, but actually it should have been http://localhost/mywebapplication/images/logo.gif. I want the image to be shown, but once it is deployed i dont want my JSP code to be changed whether it is deployed as default webapp or deployed with some contextName ( like mywebapplication or ourwebapplication etc.). Is my <img> tag in the above JSP is wrong or i need to do some configuration in web.xml.
Any help is appreciated
Hari
Karl Moss
Author
Greenhorn

Joined: Feb 08, 2002
Posts: 18
You need to use a relative path for your image, such as:
<img src="images/logo.gif">


Karl Moss,<br />Author of <a href="http://www.amazon.com/exec/obidos/ASIN/007222262X/ref=ase_electricporkchop" target="_blank" rel="nofollow">Java Servlets Developer's Guide</a> <br /><a href="http://www.servletguru.com" target="_blank" rel="nofollow">ServletGuru.com</a> the Companion site.
Meera Chandrasekaran
Greenhorn

Joined: Jan 08, 2002
Posts: 10
I had same issue and I had raised the question in servlet-interest mailing list and got the same answer. Happy to note that I am not alone.
I was under the impression /images/... will resolve to <web-root-of-this-web-app>/images/...
while it is not the case. "/" always resolves to
<default-web-root-of-server>/....
But somehow I am convinced yet. I feel I am missing something and there should be a way that case 1 works. let me know if you hit upon anything.
Hari babu
Ranch Hand

Joined: Jun 25, 2001
Posts: 208
Originally posted by Karl Moss:
You need to use a relative path for your image, such as:
<img src="images/logo.gif">

Hi Karl,
If i use <img src="images/logo.gif">, it tries to get the logo.gif from images folder under "Myapp" folder, which i dont have b'coz "Myapp" and "images" are at same level.
Atanu Dey
Greenhorn

Joined: Apr 25, 2002
Posts: 8
Hi Hari,
U have to put the 'images' folder inside yr 'myApp' folder. Then u can use <img src="images/logo.gif"> statement.
Atanu
Originally posted by Hari babu:

Hi Karl,
If i use <img src="images/logo.gif">, it tries to get the logo.gif from images folder under "Myapp" folder, which i dont have b'coz "Myapp" and "images" are at same level.

[ April 25, 2002: Message edited by: Atanu Dey ]
Hari babu
Ranch Hand

Joined: Jun 25, 2001
Posts: 208
Originally posted by Atanu Dey:
Hi Hari,
U have to put the 'images' folder inside yr 'myApp' folder. Then u can use <img src="images/logo.gif"> statement.
Atanu

[ April 25, 2002: Message edited by: Atanu Dey ]

Hi Atanu,
If i put images folder in "Myapp" directory it will work, but what if i have another directory "module1" in my web folder and i want the same logo image in one of its JSP,then i should copy the images folder under module1 also, which is waste, as iam repeating the same set of files (here logo.gif). I want to have a single set of files
Thanks
Atanu Dey
Greenhorn

Joined: Apr 25, 2002
Posts: 8
Hi Hari,
If u want to have one more directory 'module1' in the 'MyApp' directory and want to access the same logo.gif in a JSP file inside that 'module1' folder, just refer to the image like this:
<img src="../images/logo.gif">. Likewise u can have multiple JSPs in multiple folders accessing the same image file in 'images' folder.
Hope this will solve yr problem. let me know.
Atanu
Originally posted by Hari babu:

Hi Atanu,
If i put images folder in "Myapp" directory it will work, but what if i have another directory "module1" in my web folder and i want the same logo image in one of its JSP,then i should copy the images folder under module1 also, which is waste, as iam repeating the same set of files (here logo.gif). I want to have a single set of files
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Deployment issue
 
Similar Threads
not able to deploy application
Tomcat 404 error
mock exam doubt
JSP and deployment
New to Weblogic