I cannot find any restriction like in the JSP 2.0 specification. Where did you see that?
Also this kind of restriction doesn’t make sense to me, all it should care about is the opening <%= and the closing %>. Below is how the specification defines this in section JSP.9.4.3, and my code conforms to that.
Original Equivalent Text
<%= expression %> out.print(expression)