Reputation: 2110
I'm trying to input some java code in my jsp however the following exception is being generated :
org.apache.jasper.JasperException: /Home.jsp(31,8) PWC6203: Scripting elements ( <%!, <jsp:declaration, <%=, <jsp:expression, <%, <jsp:scriptlet ) are disallowed
My jsp contains an if statement and will check data. If it matches, some html code is displayed, otherwise, another code is displayed
<% String username = session.getAttribute("loggedIn").toString();
String actual = "${message.message}";
if(username.equals(actual)){%>
<div style="background-color:#fff380;">
...
</div>
<%} else { %>
<div>
...
</div>
<%}%>
Does anyone know why this type of error is being generated please? thanks a lot
Upvotes: 1
Views: 5546
Reputation: 692281
Sciptlet usage has probably been configured invalid (see http://www.java-samples.com/showtutorial.php?tutorialid=548). And this choice was a wise choice, because scriptlets shouldn't be used in JSPs anymore. Use the JSTL and the EL:
<c:choose>
<c:when test="${loggedIn == message.message}">
...
</c:when>
<c:otherwise>
...
</c:otherwise>
</c:choose>
Moreover, even if scriplet was valid, you can't use the JSP EL inside scriptlet code.
Upvotes: 2