File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Problem using Java Beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem using Java Beans" Watch "Problem using Java Beans" New topic
Author

Problem using Java Beans

Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Hi I'm getting this error...



Bean File



I can't seem to figure it out... Help please... Thanks...

[ October 18, 2005: Message edited by: Timothy Sam ]
[ October 18, 2005: Message edited by: Bear Bibeault ]

SCJP 1.5
http://devpinoy.org/blogs/lamia/ - http://everypesocounts.com/
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

What error?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1844

You must import the bean to Jsp file before using int on jsp :
employee.EmployeeBean


Krishna Srinivasan
Spring Tutorials, OCAJP Mock Questions, 400+ OCPJP Mock Questions
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Sorry... Here's the error report...



type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException
org.apache.jasper.runtime.JspRuntimeLibrary.internalIntrospecthelper(JspRuntimeLibrary.java:359)
org.apache.jasper.runtime.JspRuntimeLibrary.introspecthelper(JspRuntimeLibrary.java:306)
org.apache.jsp.employee.showemployee_jsp._jspService(org.apache.jsp.employee.showemployee_jsp:96)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.NullPointerException
org.apache.jasper.runtime.JspRuntimeLibrary.internalIntrospecthelper(JspRuntimeLibrary.java:320)
org.apache.jasper.runtime.JspRuntimeLibrary.introspecthelper(JspRuntimeLibrary.java:306)
org.apache.jsp.employee.showemployee_jsp._jspService(org.apache.jsp.employee.showemployee_jsp:96)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.12 logs.
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
You must import the bean to Jsp file before using int on jsp

Hi, do you mean this like:

<%@ page import="java.sql.*" %>

Thanks...
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You don't need to import it.
The useBean tag will handle that for you.



You're giving the bean an id of "eb".
In your setProperty tag, you need to refer to it with that name.

<jsp:setProperty name="eb" property="fName" value......
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Thanks for your reply Ben that was very helpful. However a new problem arised... I hope you won't mind me asking...


type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Cannot find any information on property 'fName' in a bean of type 'employee.EmployeeBean'
org.apache.jasper.runtime.JspRuntimeLibrary.internalIntrospecthelper(JspRuntimeLibrary.java:363)
org.apache.jasper.runtime.JspRuntimeLibrary.introspecthelper(JspRuntimeLibrary.java:306)
org.apache.jsp.employee.showemployee_jsp._jspService(org.apache.jsp.employee.showemployee_jsp:96)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.12 logs.



Here's my code...

showemployee.jsp




and my bean file...

EmployeeBean.java

Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I wonder if Jasper got thrown off by the two upper case letters just after the "get" portion of the property.

Try property="fname".
[ October 19, 2005: Message edited by: Ben Souther ]
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Tried changing property="fName" to property="fname"... Still won'y work... Thanks for the quick response...
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I just tried with FName and it worked.

Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
FINALLY WORKED! Thanks a lot! What could be the reason fName didn't work? It's clearly defined in my javabean...
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I'm guessing that it's trying to prevent things like:
property="sSN" for properties that are acronyms like getSSN().

I haven't seen the exact syntax rules in the JSP spec in a long time.
The link is in my signature if you want to look for them.
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Thank you for you reply! that was very very very helpful!
 
 
subject: Problem using Java Beans