Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2006-07-11
3
Medium Priority
?
273 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
  • 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 1000 total points
ID: 17088118
If you dont want to use scriptlet then try to use <bean:write> or <bean:message> tag.
0

Featured Post

Independent Software Vendors: 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

High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Steps to fix error: “Couldn’t mount the database that you specified. Specified database: HU-DB; Error code: An Active Manager operation fail”
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

916 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