I have some jsp code:
<%
if((Integer.parseInt((rs.getString("setter")).trim())==1) and
(Integer.parseInt((rs.getString("scrutinizer")).trim())==1))
{
out.println("Both")
}
else if(Integer.parseInt((rs.getString("setter")).trim())==1)
{
out.println("Question Setter");
}
else if(Integer.parseInt((rs.getString("scrutinizer")).trim())==1)
{
out.println("Scrutinizer");
}
%>
I get this error:
) Expected
; Expected
else without if Illegal Start of type. missing return statement
What is the error message trying to say?
if((Integer.parseInt((rs.getString("setter")).trim())==1) && (Integer.parseInt((rs.getString("scrutinizer")).trim())==1))
{
out.println("Both")
}
You are missing a semicolon. Also, in Java AND
is denoted as &&
:
if((Integer.parseInt((rs.getString("setter")).trim())==1) && (Integer.parseInt((rs.getString("scrutinizer")).trim())==1))
{
out.println("Both");
}
Use &&
instead of and
.
put ;
after out.println("Both")
line
Like this out.println("Both") ;
You need to remove the "AND" and replace it with && instead.
You're also missing a semi colon at the end of the print both line.
<%
if(Integer.parseInt(rs.getString("setter")).trim()==1 && Integer.parseInt(rs.getString("scrutinizer")).trim()==1)
{
out.println("Both");
}
else if(Integer.parseInt((rs.getString("setter")).trim())==1)
{
out.println("Question Setter");
}
else if(Integer.parseInt((rs.getString("scrutinizer")).trim())==1)
{
out.println("Scrutinizer");
}
%>
You get Expected ; , because you forgot a ; . You should have this:
out.println("Both");
instead of: out.println("Both")
You should be using the operator && here instead of and :
if((Integer.parseInt((rs.getString("setter")).trim())==1) and (Integer.parseInt((rs.getString("scrutinizer")).trim())==1))
the corrected code should look like this:
<% if((Integer.parseInt((rs.getString("setter")).trim())==1) && (Integer.parseInt((rs.getString("scrutinizer")).trim())==1))
{
out.println("Both");
}
else if(Integer.parseInt((rs.getString("setter")).trim())==1)
{
out.println("Question Setter");
}
else if(Integer.parseInt((rs.getString("scrutinizer")).trim())==1)
{
out.println("Scrutinizer");
} %>
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.