0

I'm having a strange issue with JSP.

out.println(challenge.name);
${challenge.name}
<p>Challenge '${fn:escapeXml(challenge.name)}'.</p>

Strangely only the first line works, the other ones don't return anything. Why is this the case?

here is a more complete part of the code as requested via the comments:

<%
    Challenge challenge = ObjectifyService.ofy()
        .load()
        .type(Challenge.class)
        .id(challengeId)
        .now();

    if (challenge == null) {
%>
<p>Challenge with id '${fn:escapeXml(challengeId)}' could not be found.</p>
<%
    } else {
%>

<p>Challenge <% out.println(challenge.name); %></p>
<p>by <% out.println(challenge.author_name); %></p>

<%
    }
%>

Originally the test took place where I'm now printing with println.

Jan B
  • 518
  • 1
  • 3
  • 18
  • challenge must be a scripting variable and not a scoped variable. You should post your code. – rickz Mar 04 '16 at 15:25
  • updated the question – Jan B Mar 04 '16 at 16:01
  • Please read http://strutscr.uw.hu/0059.html http://stackoverflow.com/questions/3570191/i-can-pass-a-variable-from-a-jsp-scriptlet-to-jstl-but-not-from-jstl-to-a-jsp-scriptlet-without-an-error http://stackoverflow.com/questions/25893913/how-to-pass-java-variables-from-scriptlets-to-cwhen-expression-in-jstl – rickz Mar 04 '16 at 16:34

0 Answers0