JavaBean
Hi All
im new in JSP! im trying to use javabena. i've a class named UserBean in "webapps\ROOT\Practice\WEB-INF\classes\UserBean.class" (Tomcat4.1 version). in a blank jsp file i use
========================================================
<%
<jsp:useBean id="user" class="UserBean" />
<jsp:setProperty name="user" property="userID" value="sltarif">
<jsp:setProperty name="user" property="userPassword" value="ariful">
<jsp:setProperty name="user" property="userName" value="Ariful Haque">
UsreID is = $<jsp:getProperty name="user" property="userID">
UsrePassword is = $<jsp:getProperty name="user" property="userPassword">
UsreID is = $<jsp:getProperty name="user" property="userName">
%>
========================================================
When i try to run the page.. this showing an error tha is:
========================================================
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 60 in the jsp file: /Practice/index.jsp
Generated servlet error:
[javac] Compiling 1 source file
D:\Tomcat4.1\work\Standalone\localhost\_\Practice\index_jsp.java:99: > expected
<jsp:useBean id="user" class="UserBean" />
^
========================================================
and more also.. im not understanding whats wrong with it.. if any 1 know about it.. plz help me...
Thank you
Arif
[1565 byte] By [
arifbda] at [2007-10-2 18:18:45]

Hello arif
I m pawan gupta
I dont know what is your problem actully but as you told that your jsp page in not getting compiled so do one thing that
first of all put you bean in a package that is
put the following line in your jsp as first line of program
package inf;
and then compile your Java bean
remember that their should be a folder namedinfinside classes folder means structure shold be
\WEB-INF\classes\inf
and then the use it in your jsp page as
<jsp:useBean id="your bean id" classes="inf.UserBean" />
might be it will work
becoz i bean should alway be inside a package;
try
pawan gupta
Dear Mr Grpta
Thnx for trying to help. when i was restructuring the code, i find that, i was trying to use <jsp:use Bean... /> inside <% %> jsp block. then i remove the block and compile the UserBean class inside a package named "com". as u say, i use it in \WEB-INF\classes\com directory and try to run the jsp page. then previous error was gone but it still not run. it say now..
========================================================
org.apache.jasper.JasperException: /Practice/index.jsp(9,1) The value for the useBean class attribute com.UserBean is invalid.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
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)
========================================================
i just use for jsp is
=========================================================
<HTML>
<HEAD><TITLE>JavaBean Test</TITLE></HEAD>
<BODY>
<h1>Introduction to JavaBean</h1>
<jsp:useBean id = "ubean" class = "com.UserBean" />
<jsp:getProperty name="ubean" property="userName"/>
</BODY>
</HTML>
========================================================
if you know, where might the problem is.. then plz inform me...
Thanks again
Arif