-
javaBeans with JSP
Hello everyone..
i have one problem..
i want to use javaBeans with JSP in JBuilder(Eclipse) IDE.
i hv one JSP named :
'BeanJsp.jsp' with code :
<jsp:useBean id="the" class="CalcBean"/>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%
int i = 4;
int j = the.doubleIt(i);
out.print("2*4=" + j);
%>
</BODY>
</HTML>
and one JavaBean named:
'CalcBean.java' with code :
public class CalcBean {
CalcBean(){ }
public int doubleIt(int number) {
return 2 * number;
}
}
while running on Tomcat 5.5 server it is giving error:
"org.apache.jasper.JasperException: /BeanJsp.jsp(2,0) The value for the useBean class attribute CalcBean is invalid."
this problem is only with JBuilder IDE..on Gel IDE it is working..
pls solve my problem n do reply soon...
Thanx.
:: pankaj
-
This looks like it is due to the fact that tomcat can not find the CalcBean class. Where are you saving CalcBean.java?
If it is not in the default package (I.E. no package declaration at the top of CalcBean.java) then you would need to add an import to the jsp page or fully qualify the CalcBean reference (If the CalcBean file was under com/onevisionsupport/example then the useBean would need to be com.onevisionsupport.example.CalcBean).
If this doesn't help let me know also if you could provide details of the structure you are using and I will see if I can work it out for you.