Mohammad Ramzan wrote:
>
>
> Hello,
>
> I am having trouble,
> The scenario is:
> To create a new project a user has to fill out three forms in sequence.
> For each form I am storing the form values in separate beans using
> jsp:setProperty, the beans have session scope.
> I can then submit these variables into the database once the user
> reaches the last stage.
>
> The problem:
> This works fine but when the user goes to create another new project the
> form values in the beans are not be overwritten, this is because of the
> session scope.
>
> The question:
> How can I re-initialise a bean for every request but still give it
> session scope so I can submit the values to the DB, two pages later?
>
> I have been going round in circles on this one, any help is much
> appreciated.
Define a property for your bean that resets all the other properties,
e.g.
package com.mycompany;
public class MyBean {
private String myProperty;
public void setMyProperty(String s) {
myProperty = s;
}
public void setReset(String s) {
myProperty = null;
}
}
and then in the JSP page:
<jsp:useBean id="myBean" class="com.mycompany.MyBean" scope="session" />
<jsp:setProperty name="myBean" property="reset" value="ignored" />
<jsp:setProperty name="myBean" property="*" />
The first setProperty resets all properties and the second set all
properties matching request parameters from the form.
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
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