I'm pretty sure Mingzhe Zhu's suggestion should work and that it wouldn't
result in duplicate variable names.  Login.jsp and Authenticate.jsp each end
up as separate .java files.  The useBean line ends up in the .java file as
something like :
LoginBean loginHandler = (LoginBean)session.get("loginHandler");
if(loginHandler == null)  // bean doesn't exist in session yet, so create
and add it
{
    loginHandler=new LoginBean();
    session.put("loginHandler", loginHandler);
}

Both Login.jsp AND Authenticate.jsp should have this code in them so that
the "loginHandler" variable will be available to the rest of the code in
them.  The only way you should get duplicate variable names is if you had
useBean twice in the same file using the same id (i.e. variable name).

Hope that helps,
Brien Voorhees

----- Original Message -----
From: Wong Mary <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, October 04, 1999 6:10 PM
Subject: Re: beans in jsp


> On Mon, 4 Oct 1999 17:48:44 -0700, Mingzhe Zhu <[EMAIL PROTECTED]>
wrote:
>
> >Try to copy the line
> ><jsp:useBean id="loginHandler" class="LoginBean" scope="session"/>
> >and paste to the second file.
>
> Doing the above would result in a error of duplicate variable names.
>
> Actually, I've gotten over this hurdle by making the authenticate.jsp as
follows.
>
> <html>
> <%! LoginBean formHandler; %>
> <%
>    formHandler = (LoginBean)session.getValue("loginBean");
>    if ( null!=formHandler)
>       formHandler.processRequest();
>    else
>       System.out.println("null handlerBean in request");
> %>
>
> <%@ include file ="/jsp/login/login.jsp" %>
> </html>
>
>
>
> The challenge now is in returning to the original login.jsp as indicated
in
> the <%@ include file = ...> tag.  That part isn't working right.
>
> Any suggestions out there?
>
> -Mary
>
>
>
>
> >
> >-ming
> >
> >Wong Mary wrote:
> >
> >> Hello,
> >>
> >> I have a jsp with various form inputs.  The inputs are mapped to bean
> >> properties.  I want to start processing the form only after all the
> >> submitted properties are set.  To achieve this effect, I am specifying
> >> a helper jsp as the form action in the jsp which submits the input.
> >>
> >> Let's take login as an example.
> >>
> >> in login.jsp:
> >> ...
> >> <jsp:useBean id="loginHandler" class="LoginBean" scope="session"/>
> >> ...
> >> <form method=post action=authenticate.jsp>
> >> User name:  <input type=text name=username>
> >> Password:  <input type=password name=passwd>
> >> <input type=submit value="Submit">
> >> </form>
> >> ...
> >>
> >> in authenticate.jsp:
> >> <html>
> >> <%
> >>     loginHandler.processRequest();
> >> %>
> >> <%@ include file ="login.jsp" %>
> >> </html>
> >>
> >> If I process the 2 pages as they are, the "loginHandler" in the 2nd
page
> >> will be tagged as undefined parameter or class during page compilation.
> >> What is the proper way to convey the sharing of this parameter.
> >>
> >> Also, is this approach of using the form action in the first jsp to
> >> ensure entry to backend processing only after setting necessary states
> >> a valid way to go?  Or are there better ways to go about it?  (BTW, all
> >> this similates the afterSet() used in ATG Dynamo.)
> >>
> >> Thanks,
> >> -Mary
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> FAQs on JSP can be found at:
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to