JavaBeans and Scope :- Model Components in Struts Frameworks

JavaBeans and Scope :- Model Components in Struts Frameworks

Previous Home Next

 

JavaBeans can be stored a number of different collections of attributes.the rules defining lifetime and visibility are called the scope of those beans.

 JavaBeans can be stored a number of different collections of attributes.the rules defining lifetime and visibility are called the scope of those beans.
  • page - This is used for visible within a single JSP page, for the lifetime of the current request.
  • request - This is used for visible within a single JSP page, as well as to any page or servlet that is included in this page, or forwarded to by this page.
  • session - Thsi are visible to all JSP pages and servlets that participate in a particular user session .This bean handle one or more requests. 
  • application - This are visible to all JSP pages and servlets that are part of a web application.
LoginForm.java

package com.r4r.struts;
import org.apache.struts.action.ActionForm;
@SuppressWarnings("serial")
public class LoginForm extends ActionForm {
	private String name;
	private String password;
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
}

Previous Home Next