This all sounds weird (why not separate the two?), but you could try having
the Servlet place itself inside one of the scopes, for example:

in servlet...
context.setAttribute("ServletBean", this);

in jsp...
<jsp:useBean id="ServletBean" scope="application"
class="com.foo.BeanServlet">
</jsp:useBean>

or

in servlet...
request.setAttribute("ServletBean", this);

in jsp...
<jsp:useBean id="ServletBean" scope="request" class="com.foo.BeanServlet">
</jsp:useBean>

Be careful about multithreading issues.

-----Original Message-----
From: Phil Hedley [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 01, 2000 6:15 PM
To: [EMAIL PROTECTED]
Subject: Servlet and Bean as One


Hi all,

I have created a servlet which processes the output of a jsp page, and also
provides the input for the next jsp page.
The class is actually a Bean and a Servlet.
The jsp pages use the <jsp:useBean> directive and appropriate get methods.

The problem I am having is that I get 2 instances of the same class.
The first instance is created when I load abc.jsp, the second is created
when I
submit the form on abc.jsp which calls the servlet.

What I need is for the server to use the same instance created by the jsp
page.

Is there a way round this ?

Thanks,
Phil Hedley

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to