Testing environment: netbeans7.11 + glassfish 3.11
here is the jsp, class code:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:useBean id="gb" class="GameBean" scope="session" />
<jsp:setProperty name="gb" property="operation" value="OOOOOOOOO" />
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1><jsp:getProperty name="gb" property="operation" /></h1>
</body>
</html>
public class GameBean {
private String operation; //operation
public void setOperation (String operation) {
this.operation = operation;
}
public String getOperation () {
return this.operation;
}
}
Error message: org.apache.jasper.JasperException: PWC6054: Cannot find any information on property 'operation' in a bean of type 'GameBean'
C:\Users\ray\Desktop\OU\COMPS311\tma02\web\nbproject\build-impl.xml:612: Java returned: 1 BUILD FAILED (total time: 1 second)
why can’t detect the operation?
After set the method to public
Compiling 1 source file to C:\Users\test\web\build\generated\classes
C:\Users\test\web\build\generated\src\org\apache\jsp\GameBean_jsp.java:47: error: cannot find symbol
GameBean GameBean = null;
^
symbol: class GameBean
location: class GameBean_jsp
C:\Users\test\web\build\generated\src\org\apache\jsp\GameBean_jsp.java:49: error: cannot find symbol
GameBean = (GameBean) _jspx_page_context.getAttribute("GameBean", PageContext.SESSION_SCOPE);
symbol: class GameBean
location: class GameBean_jsp
C:\Users\test\web\build\generated\src\org\apache\jsp\GameBean_jsp.java:51: error: cannot find symbol
GameBean = new GameBean();
symbol: class GameBean
location: class GameBean_jsp
C:\Users\test\web\build\generated\src\org\apache\jsp\GameBean_jsp.java:66: error: cannot find symbol
out.write(org.apache.jasper.runtime.JspRuntimeLibrary.toString((((GameBean)_jspx_page_context.findAttribute("GameBean")).getOperation())));
symbol: class GameBean
location: class GameBean_jsp
4 errors
C:\Users\test\web\nbproject\build-impl.xml:629: The following error occurred while executing this line:
C:\Users\test\web\nbproject\build-impl.xml:263: Compile failed; see the compiler error output for details.
Make your
getOperation()andsetOperation(...)methods public.After your updates the new issue seems to be that your
GameBeanis defined in some package which you are not importing (or using the fully qualified name) in JSP.