| | |
Java bean problems! Argh
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2008
Posts: 32
Reputation:
Solved Threads: 0
Okay, here we go. I am trying to learn how to use javabeans properly and so I've created a small bean which just writes text to the screen. I keep getting the error:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the generated java file
Only a type can be imported. mybeans.processFormBean resolves to a package
and can't figure out what to do. Here is my code:
nob.jsp
example.java (but I have obviously compiled it)
I have checked the package names and the folders they are in etc, here is my classpath: .;C:\Program Files\Java\jre1.6.0_04\lib\ext\QTJava.zip
Thanks for your help!
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the generated java file
Only a type can be imported. mybeans.processFormBean resolves to a package
and can't figure out what to do. Here is my code:
nob.jsp
java Syntax (Toggle Plain Text)
<%@ page import="mybeans.processFormBean" %> <jsp:useBean id="example" class="beans.example" /> <form name="example" action="nob.jsp" method="get"> <input type="text" name="value"> <input type="submit" value="submit"> </form> <jsp:getProperty name="value" property="value" /> <%= example.getValue() %>
example.java (but I have obviously compiled it)
java Syntax (Toggle Plain Text)
package beans; import java.sql.*; public class example { private String value = "cheese"; public void setValue(String value) { this.value = value; } public String getValue() { return value; } public void test() { System.out.println("The bean worked"); } }
I have checked the package names and the folders they are in etc, here is my classpath: .;C:\Program Files\Java\jre1.6.0_04\lib\ext\QTJava.zip
Thanks for your help!
Your problem seems to be this line in your JSP file:
>
What exactly is processFormBean here? Is it a package? Are you trying to import all the classes from the processBean package? If yes, then you are doing it the wrong way. To import all the classes of a particular package, you need to do something like:
As a rule of thumb, *never* keep anything in your JDK/JRE installation directory. Create a separate lib folder for your application which will contain all the libraries specifically used by your applications. In case of a web application, this would be the lib directory inside WEB-INF. Also, the lib directory implicitly forms a part of your classpath so you don't have to explicitly set it anywhere.
>
<%@ page import="mybeans.processFormBean" %> What exactly is processFormBean here? Is it a package? Are you trying to import all the classes from the processBean package? If yes, then you are doing it the wrong way. To import all the classes of a particular package, you need to do something like:
<%@page import="mybeans.processFormBean.*" %> As a rule of thumb, *never* keep anything in your JDK/JRE installation directory. Create a separate lib folder for your application which will contain all the libraries specifically used by your applications. In case of a web application, this would be the lib directory inside WEB-INF. Also, the lib directory implicitly forms a part of your classpath so you don't have to explicitly set it anywhere.
I don't accept change; I don't deserve to live.
•
•
Join Date: Jan 2008
Posts: 32
Reputation:
Solved Threads: 0
OKay thanks, now I'm getting the error:
org.apache.jasper.JasperException: Attempted a bean operation on a null object.
org.apache.jasper.runtime.JspRuntimeLibrary.handleGetProperty(JspRuntimeLibrary.java:603)
org.apache.jsp.nob_jsp._jspService(nob_jsp.java:73)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Thanks for your help :-)
org.apache.jasper.JasperException: Attempted a bean operation on a null object.
org.apache.jasper.runtime.JspRuntimeLibrary.handleGetProperty(JspRuntimeLibrary.java:603)
org.apache.jsp.nob_jsp._jspService(nob_jsp.java:73)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Thanks for your help :-)
>
This means "get the 'value' property of a bean identified by the name 'value'", but there is no such bean in your case which goes by the name of 'value'. Maybe you wanted to do something like
<jsp:getProperty name="value" property="value" /> This means "get the 'value' property of a bean identified by the name 'value'", but there is no such bean in your case which goes by the name of 'value'. Maybe you wanted to do something like
<jsp:getProperty name="example" property="value" /> ? I don't accept change; I don't deserve to live.
![]() |
Other Threads in the JSP Forum
- Previous Thread: How to create a "web.xml" file for website?
- Next Thread: Any Sample Projects in JSP??
| Thread Tools | Search this Thread |
apache backbutton combobox connection database development directorystructure dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 network parameters passing ping printinserverinsteadofclient redirect request.getparameter response servlet servletdopost()readxml sessions software ssl state_saving_method stocks sun tomcat tutorial update video web






