aspose file tools*
The moose likes Struts and the fly likes html:image src url how to set ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:image src url how to set ?" Watch "html:image src url how to set ?" New topic
Author

html:image src url how to set ?

Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 442
hi good day to all,
i using image to replace my submit button as follow :


purely <html:rewrite page=/pages/images/btnAdd.gif /> will generated the correct path for me , which result display url like myapp/pages/images/btnAdd.gif

however, when i apply it into src of html:image tag, this will result as string as shown following
<html:rewrite src="<html:rewrite page=/pages/images/btnAdd.gif />" />

below actually give me the correct result, but i try not to hardcode it(myapp)



any remedy on this ? thank you for guidance
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
How about just making it a relative reference?

First of all, you'd put <html:base> somewhere between <head> and </head>. Tha makes the current JSP the point of reference for all URLS on the page. Then, if the current page is in /myapp/pages, just specify:


Merrill
Consultant, Sima Solutions
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
I have to admit that I do not recall using the html:image tag ever. I have implemented such buttons with a <a> tag containing javascript in the href surrounding an html:img tag.

Looking at the documentation for the html:image tag, will the page attribute do what you need? The documentation for the attribute says "the module-relative path of the image for this input tag".

- Brent
Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 442
thanks Merrill Higginson and Brent Sterling warm reply,

i have try both solutions, here are my result :

test case 1 : put in <html:base/>

result : the html:base render to html with this


and the result of image url still show as <input type="image" name="add" src="/pages/images/btnAdd.gif ">

test case 2 : make the image tag to page as follow


it show correct result as render <input type="image" name="add" src="/DBTest/pages/images/btnAdd.gif ">

conclusion : i think in this case we should using page attribute

once again, thank you Merrill Higginson and Brent Sterling for guidance
Mike Sever
Ranch Hand

Joined: Jul 24, 2006
Posts: 56
The two below solutions are heuristic and helpful.
Just provide another common way for url, store all urls (no matter whether they belong to one app/context) to a property file or database, then it will NOT impact any existing code but only change property file or database if some relative/full paths are changed.


<i>Mike</i>
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
To clarify the usage of the base tag...that sets a base url/directory that the browser should will for all subsequent calls. You would then have to use a relative path to your image. Something like this src="../images/btnAdd.gif". Though, I agree that the usage of the page attribute is cleaner.

- Brent
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: html:image src url how to set ?