tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Denise Mangano <Deni...@complusdata.com>
Subject Java Bean Scope questions (a lengthy one)
Date Wed, 08 Jan 2003 02:18:37 GMT
She's back :)  Was trying to give everyone a break from my endless questions
- but I missed the learning too much ;) - plus I got stumped again :-P  Now,
I don't blame anyone for not wanted to sift through all this, but any
help/advice is greatly appreciated :)  
 
Here's the latest (includes a little recap of my project):
 
So I have my form where I collect all the user information that on submit
calls the controller CCProcess.jsp which instantiates my formBean (instance
of FormBean class) and sets the properties equal to the input values in my
form.  Then after using formBean to validate my form, providing all input is
correct, I forward control to Verify.jsp.  Verify.jsp also uses formBean and
displays all the properties of formBean for verification. (up to this point
it all works like a charm - thanks to some help ;) )
 
The user reviews the information, then clicks on a "Submit" button which
executes the form action="CCSubmit.jsp".  What I try to do here is have
access to formBean properties.  I also need to instantiate a new bean called
transaction (instance of Transaction class).  I then need to set some of the
transaction properties equal to the formBean properties.  However, when I
try display my information to the browser, all properties (both of formBean
and transaction) are null.
 
Question #1: Why does CCSubmit.jsp not have access to formBean properties.
I am thinking this is because technically by submitting a form with an
action of "CCSubmit.jsp" control isn't being forwarded to CCSubmit.jsp so
the instance of formBean isn't forwarded.  The scope of formBean is request.
Is that the correct scope to use?  **I need to have access to formBean
properties from the moment it is instantiated to the moment the application
has completed, but it has to be unique to each user of the webapp.**   How
could I accomplish this?
 
Question #2: Is it possible to use two beans within a single jsp page?  I
would imagine that it is, and if so I believe once I gain access to formBean
properties, my transaction properties will no longer be null. (I included
some code below... is this legal?)

Question #3:  I include a button to give the option to go back and make
changes.  If the user should desire to go back and make changes, control
should be forwarded to Retry.jsp on button click.  I need to program this
button in a way so that when Retry.jsp is recalled it will still have access
to formBean properties.How do I program this? My last attempt using
<jsp:forward> cause Retry.jsp to load automatically when Verify.jsp was
loaded (sorry again Noel ;) ). 
 
Example of bean use in my CCSubmit.jsp:

<%@ page import="com.complusdata.beans.*" %>
<%@ page import="java.io.*" %>
 
<jsp:useBean id="formBean" class="com.complusdata.beans.FormBean"
scope="request"/>
 
<jsp:useBean id="transaction" class = "com.complusdata.beans.Transaction"
scope="request">
  <%-- need to set each property individually --%>
  <jsp:setProperty name="transaction" property="email"
value="<%=formHandler.getEmail()%>"/>
  <jsp:setProperty name="transaction" property="ccNum"
value="<%=formBean.getCCNumber()%>"/> 
  <jsp:setProperty name="transaction" property="exp"
value="<%=formBean.getExpires()%>"/>
  <jsp:setProperty name="transaction" property="street"
value="<%=formBean.getAddress()%>"/>
  <jsp:setProperty name="transaction" property="zip"
value="<%=formBean.getPostalCode()%>"/>
  <jsp:setProperty name="transaction" property="amount" value="<%= cents
%>"/>
  <jsp:setProperty name="transaction" property="orderNum"
value="<%=formBean.getTransactionId() %>"/>
  <jsp:setProperty name="transaction" property="state"
value="<%=formBean.getState() %>"/>
</jsp:useBean>
 
(Wow thats a mouthful!!)  Thanks in advance!! 
Denise


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message