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 following
<%= foo %>
is thus equivalent to
out.print(foo);
request.getSession(true).setAttribute("state","firstNumber")
is an expression whose type is void. And you can't print a void.
What you want is simply
<% request.getSession(true).setAttribute("state","firstNumber") %>
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.