Solved

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

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
jquery form plugin 4 152
EJB MDB example 4 76
authenticate preemptively soap ui option 3 108
JSONSerializer.toJSON in JSP generating error 8 53
A procedure for exporting installed hotfix details of remote computers using powershell
A safe way to clean winsxs folder from your windows server 2008 R2 editions
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the fileā€¦
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now