Solved

help me regarding specifying absolute path in Struts view file...

Posted on 2006-07-11
3
268 Views
Last Modified: 2010-04-01
Hi ,
I am using Struts Framework for my web development.

Following is directory structure inside my webroot folder:-
-Econify
     +src
     -webroot
          +JSP
          +images
          +css
          +js
          +META-INF
          +WEB-INF
     
Now In my JSP page when I want to displpay image, I have to use there something like following:-
<img src="<%=request.getContextPath()%>/images/menutopcorn.gif" height="20" width="13">
but, I dont want to use each time <%=request.getContextPath()%> to retieve base path. Also I dont want to use this jsp scriptlet at all in my JSP.
Is there any other solution for above ?
like I should just type just following
<img src="/images/menutopcorn.gif" height="20" width="13">
& I should get the proper output.

How should I do that?

Thanx in advance.
Prash
0
Comment
Question by:Econify
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Expert Comment

by:Meritor
ID: 17080099
assuming your JSP file is loacated in (webroot/jsp) directory and your image file is in (webroot/images) directory

Here is your solution
<img src="../images/menutopcorn.gif" height="20" width="13">

Explanation:

 Your file is in Webroot/JSP now you have to come to one level up for getting access to images directory which is at the same level as JSP direcotry. For this put '../' after that you can access all directories under the webroot directory (images,css,js etc.,)

Regards,
Meritor
0
 

Author Comment

by:Econify
ID: 17080154
hey,
I already know this method in HTML. but I want something that should be unique in all files like something we can do using <html:base /> tag. So that whatever is the location of file, I have to only write path as
<img src="/images/menutopcorn.gif" height="20" width="13">
How this should be done?

thanx.
0
 
LVL 4

Accepted Solution

by:
Meritor earned 500 total points
ID: 17088118
If you dont want to use scriptlet then try to use <bean:write> or <bean:message> tag.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question