Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9124687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:37:32+00:00 2026-06-17T06:37:32+00:00

We store HTML markup inside XML documents and unmarshall using JiBX. We also use

  • 0

We store HTML markup inside XML documents and unmarshall using JiBX. We also use Spring and when one of these objects is added to the model, we can access it in the JSP via EL.

${model.bookshelf.columnList[0].linkList[0].htmlMarkup}

Nothing groundbreaking. But what if we want to store EL expressions in the HTML markup? For example, what if we want to store the following link?

<a href="/${localePath}/important">Locale-specific link</a>

… and display it in a JSP where LocalePath is a request attribute.

Or even more interesting, what if we want to store the following?

The link ${link.href} is in column ${column.name}.

… and display it inside a nested JSP forEach…

<c:forEach var="column" items="${bookshelf.columnList}">
    <c:forEach var="link" items="${column.linkList}">
        ${link.htmlMarkup}
    </c:forEach>
</c:forEach>

These EL expressions in request attributes are never evaluated. Is there a way get them to evaluate? Something like an “eval” tag? Token replacement works in the first example, but not in the second and isn’t very robust.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:37:33+00:00Added an answer on June 17, 2026 at 6:37 am

    If I understand it right: you are looking for a way to evaluate an EL expression at runtime that is stored inside another value provided by an EL expression – something like recursive EL evaluation.

    As I could not find any existing tag for this, I quickly put together a proof-of-concept for such an EvalTag:

    import javax.el.ELContext;
    import javax.el.ValueExpression;
    import javax.servlet.ServletContext;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.SimpleTagSupport;
    
    public class SimpleEvalTag extends SimpleTagSupport {
        private Object value;
    
        @Override
        public void doTag() throws JspException {
            try {
                ServletContext servletContext = ((PageContext)this.getJspContext()).getServletContext();
                JspApplicationContext jspAppContext = JspFactory.getDefaultFactory().getJspApplicationContext(servletContext);
                String expressionStr = String.valueOf(this.value);
                ELContext elContext = this.getJspContext().getELContext();
                ValueExpression valueExpression = jspAppContext.getExpressionFactory().createValueExpression(elContext, expressionStr, Object.class);
                Object evaluatedValue =  valueExpression.getValue(elContext);
                JspWriter out = getJspContext().getOut();
                out.print(evaluatedValue);
                out.flush();
            } catch (Exception ex) {
                throw new JspException("Error in SimpleEvalTag tag", ex);
            }
        }
    
        public void setValue(Object value) {
            this.value = value;
        }
    }
    

    Related TLD:

    <?xml version="1.0" encoding="UTF-8"?>
    <taglib version="2.1" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd">
      <tlib-version>1.0</tlib-version>
      <short-name>custom</short-name>
      <uri>/WEB-INF/tlds/custom</uri>
      <tag>
        <name>SimpleEval</name>
        <tag-class>SimpleEvalTag</tag-class>
        <body-content>empty</body-content>
        <attribute>
          <name>value</name>
          <required>true</required>
          <rtexprvalue>true</rtexprvalue>
          <type>java.lang.Object</type>
        </attribute>
      </tag>
    </taglib>
    

    Usage:

    <custom:SimpleEval value="${someELexpression}" />
    

    Note:

    I’ve tested it using Tomcat 7.0.x / JSP 2.1, but as you can see in the source code, there is no special error handling etc., because it’s just some proof-of-concept.

    In my tests it worked for session variables using ${sessionScope.attrName.prop1} and also for request parameters using ${param.urlPar1} but as it uses the current JSP’s expression evaluator I suppose it should work for all other “normal” EL expressions, too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What datatype is the best to store html content and documents like pdf's, excel
I currently have html markup stored in xsl and xml. This has previously enabled
I use google Maps Api v3 to render google map inside colorbox using ajax
My goal is to store some html-formatted data in a variable, then echo it
Please need someone's expertise on my link; http://360webmedia.com/Store/development/index.html In my my menu_left.jpg is displaying
I am currently processing text/html data and I wish to store my results in
I'm attempting to get rid of an app's HTML files and store their contents
<body> <div id=header> <div class=title>SPORTS STORE</div> </div> <div id=categories> <% Html.RenderAction(Menu, Nav); %> </div>
I'm definitely missing something. I have an XML file that stores HTML snippets, as
I'm attempting to select all <script type=text/html> tags in a page. I use <script>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.