0

This is my Jsp:

<%if(null != request.getAttribute(ControllerBase.MSG_NOUSER)){%>
<%ControllerBase.MSG_NOUSER.toString()%>    
<%}%>

MSG_NOUSER is a public string constant. I have "Syntax error on token ")", delete this token" on the second closing tag: <%ControllerBase.MSG_NOUSER.toString()%>. Why?

  • why do you close the jsp part each line? you can just open it in the first line and close it after the last line – ItamarG3 Nov 05 '16 at 14:36
  • 1
    Java statements end with a semi-colon. It would probably be more obvious if you put Java code in Java source files, and stopped using Java code in JSPs. http://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files – JB Nizet Nov 05 '16 at 14:38

1 Answers1

0

JSP Scriptlets are typical Java code, you need to follow Java coding convetions and syntax, so you need to change as below (; is missing for the line inside the if block):

<% if(null != request.getAttribute(ControllerBase.MSG_NOUSER)){ %>
<% ControllerBase.MSG_NOUSER.toString(); %>    
<% } %>
Vasu
  • 21,832
  • 11
  • 51
  • 67