Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, I have two JSP pages, and I'

Status
Not open for further replies.

DoraC

Programmer
May 7, 2002
98
US
Hi,

I have two JSP pages, and I'm attempting to communicate between them via a javabean.

At the top of the first page, I declare my bean as so:
Code:
<jsp:useBean id=&quot;ParmHandlerBean&quot;
             scope=&quot;application&quot;
             class=&quot;mypackage.cParmHandlerBean&quot; />

If certain conditions prevail, I launch the second JSP page via a button-click as so:
Code:
  <input type=&quot;submit&quot;
         value=&quot;Transform&quot;
         onClick=&quot;window.open('response.jsp')&quot;>

In the second JSP page (&quot;response.jsp&quot;), I attempt to use the parms contained within the bean as so:
Code:
//within a scriptlet...
String sParm = ParmHandlerBean.getParm;

when the second page launches after the button-click, an error is returned mentioning that &quot;ParmHandlerBean&quot; is unrecognized as a variable. If, however, I try to &quot;use&quot; the bean in JSP page 2 (&quot;response.jsp&quot;) I generate immediate errors, with the following message:
&quot;jsp.error.useBean.duplicate&quot;

Now, If I attempt to reference the bean in this fashion within the first JSP page (the one in which it's &quot;used&quot;), things work fine. They also work fine if I &quot;<@ include&quot; jsp page number 2 in the first page, instead of launching it when the button is clicked.

Hmmmmm, I've played around with the scope parameter of the use-bean tag, but to no avail. I would assume that this can be done (sharing bean instances across JSP pages), but what am I doing wrong?

Thanks!!
Dora
 
If, however, I try to &quot;use&quot; the bean in JSP page 2 (&quot;response.jsp&quot;) I generate immediate errors, with the following message:
&quot;jsp.error.useBean.duplicate&quot;


I assume (&quot;use&quot; the bean) means that you duplicated the <jsp:useBean ...> tag exactly as you have it in the first page into the second page? If so i don't know why that wouldn't work. I do it all the time and have no problems with it.

-pete
 
Thanks Pete,

First, sorry about the no-header post... forgot about that (whoops!)

Anyway, I figured it out... I referenced the second jsp page in the first one, but further down as part of a directive. I had it commented out (which was &quot;working&quot;, because it wasn't being displayed), but apparently that was throwing things off because when I removed it altogether it started to work as expected. Evidently the mere mention of it (comments or otherwise) was enough to throw things off..

Thanks!
dora
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top