Prev: Work at Home - Earn 50,000 Weekly Without Investment Its Not A Fake, 100% Earning Guarantee
Next: Rational argument for not defining string constant for emptystring?
From: Ken T. on 13 Mar 2010 16:24 I'm including an applet in a JSP page, but the applet requires some complete urls to some components. So it looks something like this: <jsp:plugin type="applet" archive="MyCode.jar" code="com.mydomain.MyCode" width="800" height="600"> <jsp:params> <jsp:param name="ImageURL" value="testImage.png" /> <jsp:param name="HelpURL" value="help.html" /> <jsp:param name="ExitURL" value="exit.html" /> <jsp:param name="PostURL" value="MockServer" /> </jsp:params> <jsp:fallback> <p>Unable to load applet</p> </jsp:fallback> </jsp:plugin> But I need it to look like this: <jsp:plugin type="applet" archive="MyCode.jar" code="com.mydomain.MyCode" width="800" height="600"> <jsp:params> <jsp:param name="ImageURL" value="http://www.myserv.com/path/testImage.png" /> <jsp:param name="HelpURL" value="http://www.myserv.com/path/help.html" /> <jsp:param name="ExitURL" value="http://www.myserv.com/path/exit.html" /> <jsp:param name="PostURL" value="http://www.myserv.com/MockServer" /> </jsp:params> <jsp:fallback> <p>Unable to load applet</p> </jsp:fallback> </jsp:plugin> The problem being that I want the absolute URL calculated based on where the JSP page is. So on anther server the same page might show this: <jsp:param name="ImageURL" value="http://www.another.com/some/path/testImage.png" /> For the first parameter. Now, I would think this would be easy, but I just can't work it out. I can calculate the path that I need using request.getRequestURL(), but I can't seem to substitute it in where I need it. Besides, isn't there an easy way to transform a relative URL into an absolute one? I tried using an expression language function defined in a taglib and couldn't get that to work. It seems like overkill anyway. On a side note, for future reference, if I need to get to the request object in an EL function, how do I do it other than passing it in? Thanks all! -- Ken
From: Roedy Green on 14 Mar 2010 12:19
On 13 Mar 2010 21:24:27 GMT, "Ken T." <nowhere(a)home.com> wrote, quoted or indirectly quoted someone who said : >The problem being that I want the absolute URL calculated based on where >the JSP page is. If it depends on where you are, you want a relative URL, not an absolute one. You can convert back and forth by comparing the absolute (or webroot relative) URL of source and target. You see how much they have in common. That much can be stripped off and replaced by ../ for each / in the stripped source. You can see some code to do this sort of thing at: https://wush.net/websvn/mindprod/filedetails.php?repname=mindprod&path=%2Fcom%2Fmindprod%2Fhtmlmacros%2FTools.java -- Roedy Green Canadian Mind Products http://mindprod.com Responsible Development is the style of development I aspire to now. It can be summarized by answering the question, �How would I develop if it were my money?� I�m amazed how many theoretical arguments evaporate when faced with this question. ~ Kent Beck (born: 1961 age: 49) , evangelist for extreme programming. |