You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jeff Neuenschwander <je...@collegeguy.com> on 2000/04/14 00:39:55 UTC
servlet question
This is an easy question, but I have spent the last hour looking over docs
and the web for answers, with no luck..
In JSP, you do this to use a bean
<%@ page import="package.beanname" %>
<jsp:useBean id="myBean" scope="page" class="package.beanname" />
then you refer to the bean as myBean and do whatever you want to with it..
but in a servlet, I can't get it to work properly. I am doing an
import beanname;
but do I need something like the useBean syntax in JSP? I am guessing that
is my problem, but I can't find the correct command.
Thanks,
Jeff
Re: servlet question
Posted by Christopher Stacy <cs...@crystaliz.com>.
>>>>> On Thu, 13 Apr 2000 17:39:55 -0500, Jeff Neuenschwander ("Jeff") writes:
Jeff> In JSP, you do this to use a bean
Jeff> <%@ page import="package.beanname" %>
Jeff> <jsp:useBean id="myBean" scope="page" class="package.beanname" />
Jeff> then you refer to the bean as myBean and do whatever you want to with it..
Jeff> but in a servlet, I can't get it to work properly. I am doing an
Jeff> import beanname;
Jeff> but do I need something like the useBean syntax in JSP? I am guessing that
Jeff> is my problem, but I can't find the correct command.
Please forgive me if I am misunderstanding your question.
The jsp:useBean action element instantiates a bean, so the corresponding
JAVA code in a servlet would be a constructor call ("new" statement);
you store the bean in a variable and do like bean.getFoo("bar") on it.
When compiling your code, there are the usual package and CLASSPATH issues,
some of which have been discussed here earlier today.