title: <c:url value="/faq#1" var="faqLink"> How to preserve # in exported variable which is mandatory and wrap functionality into tag?
body: <p>I'm working on application which uses # in URL's for localization purposes.  </p>
  
  <p>This means that when I hit <code>http://host:port/context/faq#1</code>  in the browser I get the properly localized page.  </p>
  
  <p>Inside JSP page, I use relative link like this:  </p>
  
  <pre><code>&lt;c:url value="/faq#1" var="faqLink"&gt;  
  </code></pre>
  
  <p>and that generates  </p>
  
  <pre><code>http://host:port/context/faq
  </code></pre>
  
  <p>Now, I know why <code>#</code> and everything after it gets truncated, and I can overcome it locally by using something like:  </p>
  
  <pre><code>&lt;c:url value="/" var="ctx" /&gt;
  &lt;c:set value="faq#1" var="relativeUrlWithHash" /&gt;
  &lt;c:set value="${ctx}${relativeUrlWithHash}" var="faqLink" /&gt;  
  </code></pre>
  
  <p>and use <code>faqLink</code> down the page in various places, but, since this will be used often, and for different links, I was trying to create custom tag call for it, to wrap that functionality i.e.</p>
  
  <p>tag call:</p>
  
  <pre><code>&lt;customTag:handleUrlWithHash relativeUrlWithHash="faq#1" exportedVariable="faqLink"/&gt;
  </code></pre>
  
  <p>tag body:</p>
  
  <pre><code>&lt;%@ attribute name="relativeUrlWithHash" required="true" type="java.lang.String" %&gt;
  &lt;%@ attribute name="exportedVariable" required="true" type="java.lang.String" %&gt;
  
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;
  
  &lt;c:url value="/" var="ctx" /&gt;
  &lt;c:set var="${exportedVariable}" value="${ctx}${relativeUrlWithHash}" scope="request" /&gt;
  </code></pre>
  
  <p>but with no success.</p>
  
  <p>Problem is that I get exception:</p>
  
  <pre><code>According to TLD or attribute directive in tag file, attribute var does not accept any expressions
  </code></pre>
  
  <p>which I don't know how to overcome.</p>
  
  <p>So, any suggestion how to pass variable to tag and get it filled with proper data would be welcome :)</p>
  
  <p>Cheers!</p>