Loading... Cancel

struts rewrite, link rewrites url with “;jsessionid=” session id. R

May 7th, 2007

hi,
on my server i found some strange problem. it was actually related with < html:rewrite page=""/ > tag. the problem was with the url rewriting, which was performed by struts tag library. struts tag library was creating an invalid URL.
for example i wrote the following code:
< img src="< html:rewrite page="${urlPrefix}"/>my-image.gif” />

as i have only wrapped “${urlPrefix}” with in html:rewrite tag. so struts tag library wrote the following output.

< img src="/mycontext/gfx/;jsessionid=825A15A08BE76581B356D6225B1A9265my-image.gif" mce_src="/mycontext/gfx/;jsessionid=825A15A08BE76581B356D6225B1A9265my-image.gif" />

which is totally a wrong url.

so how i resolved it?
very simple just fixing my weired code. now it looks like the following -
< img src="< html:rewrite page="${urlPrefix}my-image.gif"/>” />

the generated output looks like -
< img src="/mycontext/gfx/my-image.gif;jsessionid=825A15A08BE76581B356D6225B1A9265" mce_src="/mycontext/gfx/my-image.gif;jsessionid=825A15A08BE76581B356D6225B1A9265" />

here is a regex which may help you to find out the error tags:
“< (html):rewrite\s+page="(.+)"\s*/ >(.+)”

yeap it is working now :)