Hi I am facing a error named "The method print(boolean) in the type JspWriter is not applicable for the arguments (void) " with my JSP code in GAE.
In line :<%= request.getSession(true).setAttribute("state","firstNumber") %>
Here is the code:
`
<c:when test='${param.event == "NewCall"}'>
<%
Response resp1=new Response();
CollectDtmf cd= new CollectDtmf();
cd.addPlayText("Welcome. Please enter the first number. Terminate with #");
resp1.addCollectDtmf(cd);
%>
<%= request.getSession(true).setAttribute("state","firstNumber") %>
<% out.println(resp1.getXML()); %>
</c:when>
`
Please tell what am I doing wrong here. Thanks
<%= %>
expects an expression, whose value is printed to the JSP's writer. The followingis thus equivalent to
is an expression whose type is void. And you can't print a void.
What you want is simply
But of course, as it has been rehashed countless times, scriptlets should not be used in a JSP. JSPs are view components which should only generate HTML using the JSP EL, the JSTL and other custom tags. Not to mention that setting session attributes is, in general, a bad idea, and is even more a bad idea in a view component, which shouldn't have any side effect other than printing to the JSP writer.