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
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:
Moreover, even if scriplet was valid, you can’t use the JSP EL inside scriptlet code.