Why error "Attempted a bean operation on a null object."?
I am getting an error:
org.apache.jasper.JasperException: Attempted a bean operation on a null object.
but not sure why?
Here is the first JSP which I have simply called form.jsp
Then it calls another form called processForm.jsp
Please note both of the form.jsp and processForm.jsp are in the same directory.
<!-- This is form.jsp -->
<html>
<head>
<title> Welcome </title>
</head>
<body>
<h1> Welcome to the ABC Corporation Web site.
<form action="processform.jsp" method="get">
Enter your name:
<input type="text" name="userName">
Where do you live?
<input type="text" name="region">
<input type="submit" name="Submit info">
</form>
</body>
</html>
<!-- This is processForm.jsp -->
<html>
<head>
<jsp:useBean id="processFormBeanId" scope="session" class="mybeans.processFormBean" />
<jsp:setProperty name="processFormBeanId" property="*" />
<title> Welcome </title>
</head>
<body>
<h1> Welcome,
<jsp:getProperty name="processFromBeanId" property="userName" />
<h1>
You selected the following location:
<jsp:getProperty name= "processFromBeanId" property="location" />
</body>
</html>
The processform.jsp uses a bean which I have appropriately called
"processFormBeanId.java"
/* class processFormBean.java */
package mybeans;
public class processFormBean
{
private String userName;
private String location;
public void setUserName(String newValue)
{
userName = newValue;
}
public void setLocation(String locationValue)
{
location = locationValue;
}
private String getUserName()
{
return userName;
}
public String getLocation()
{
return location;
}
}
can any one help me?
Here is the full error message:
Error: 500
Location: /myJSPs/jsp/Whitehead/chap6/processform.jsp
Internal Servlet Error:
org.apache.jasper.JasperException: Attempted a bean operation on a null object.
at org.apache.jasper.runtime.JspRuntimeLibrary.handleGetProperty(JspRuntimeLibrary.java:420)
at jsp.Whitehead.chap6.processform_1._jspService(processform_1.java:88)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:484)

