Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problems when using JavaBean with JSP!!

0 views
Skip to first unread message

Bill

unread,
Feb 19, 2003, 9:40:07 PM2/19/03
to
I am trying to to run a simple javabean on my jsp page.
I am using tomcat 3.3 . I have create a folder under c:\tomcat\webapps
call test. After that I place the test.jsp which with the content

<%@ page import="myBean.*" %>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<jsp:useBean class="myBean.lineBean" id="mybean" scope="page" />
<%= mybean.stars(20) %>
</body>
</html>

inside the test folder. And I place the java file inside
c:\tomcat\webapps\examples\WEB-INF\classes\myBean. The content of the
file is as follow

package myBean;

public class lineBean
{

public String stars(int x)
{
String text = "<br>";
for (int i = 0; i < x; i++)
text = text + "*";
return text + "<br>";
}
}

And the Error message is:

Error: 500
Location: /test/test.jsp
Internal Servlet Error:

org.apache.jasper.JasperException: Unable to compile Note:
sun.tools.javac.Main has been deprecated.
C:\tomcat\work\DEFAULT\test\test_1.java:4: Package myBean not found in
import.
import myBean.*;
^
1 error, 1 warning

at org.apache.tomcat.facade.JasperLiaison.javac(JspInterceptor.java:898)
at org.apache.tomcat.facade.JasperLiaison.processJspFile(JspInterceptor.java:733)
at org.apache.tomcat.facade.JspInterceptor.requestMap(JspInterceptor.java:506)
at org.apache.tomcat.core.ContextManager.processRequest(ContextManager.java:968)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:875)
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:536)


Do I need to put the java file in some correct directory before i use
the javaBean? Or I need to configure something inside tomcat to let it
know that where to get my JavaBean? Maybe I missed some important
steps, because this is my fisrt time try to run JSP with Java Bean.

I am appertiate to whom can help me to solve this problem!! Thank you.

William Brogden

unread,
Feb 19, 2003, 10:47:18 PM2/19/03
to
"Bill" <kun...@hotmail.com> wrote in message
news:9ed69ba.03021...@posting.google.com...

> I am trying to to run a simple javabean on my jsp page.
> I am using tomcat 3.3 . I have create a folder under c:\tomcat\webapps
> call test. After that I place the test.jsp which with the content
>
> <%@ page import="myBean.*" %>
> <html>
> <head>
> <title>Untitled Document</title>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
> </head>
>
> <body bgcolor="#FFFFFF" text="#000000">
> <jsp:useBean class="myBean.lineBean" id="mybean" scope="page" />
> <%= mybean.stars(20) %>
> </body>
> </html>
>
> inside the test folder. And I place the java file inside
> c:\tomcat\webapps\examples\WEB-INF\classes\myBean. The content of the
> file is as follow

The "examples" folder is a "web application" - your JSP must be located
in the same web application if you want it to be able to see that bean
class. Also, files under classes MUST be compiled class files, JSP
will not compile your .java files for you.

--
WBB
author: Cocoon 2 Programming, web publishing with XML and Java
http://www.lanw.com/books/cocoonbook/default.htm

Bill

unread,
Feb 20, 2003, 10:42:41 PM2/20/03
to
Hello Mr. William

Follow your instruction, I get the code work properly, kindly
apperciate to your help.

0 new messages