Solved

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

Posted on 2006-07-11
3
266 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

By reading this blog, MSPs will gain insight into how to improve communications with their clients as well as establish a more profitable business.
Deploying our service is a grudge match between customer benefits and customer pain. In one corner, rolling out fixes (yay!) and delivering new features (double yay!). In the other corner, training on new features (boo – sounds like work), and chan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses

738 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