JSP and JavaBean

  JSP and JavaBean 
  JSP development portal (Author: IDEAL at 18:15 on August 10, 2000) 

  Although you can file in small orders Add a large piece of the code, but most of the Java programming code are reusable components can be called JavaBean.    ActiveX controls JavaBean told the same: they provide the known function, and is ready to repeat the use of the purpose of design. 

  JavaBean value is that it may be able to use a group of properties, and these properties will provide access to JavaBean set.    For example to the people, this person is JavaBean, and his name, social welfare safety numbers, and addresses can be characteristics.    The JSP web site, you will be basically 'JavaBean' dynamic linking to your site. 

  JavaBean assumption in the establishment of the website is built, you want to do the first thing is to tell it to use JSP page JavaBean. This work can be used <jsp: useBean> tag to complete: <jsp: useBean id = " localName "class =" com.jguru.Person "scope =" application "/>. 

  <jsp:useBean> Label id attributes you need to identify beans. Here, you provide a name for JSP page to identify beans, in addition to id attribute, you must also tell the website to Daonailiquhua beans, or It is the Java category name.    Attribute types provided in the various methods of how to find it, the final component is a necessary attribute scope. Attributes with the help of the scope, you can tell beans, it should be a single page (the default) [scope = "page" ;] as a requested web page [scope = "request"]; calls for the period of [scope = "session"]; or for the entire application process [scope = "application"] to safeguard its own information, the terms of the scope of calls , you can easily JSP page in the maintenance of the project, such as Cart. 

  But you declaration of a JavaBean, you can access it on the characteristics of setting it.    To achieve a value of the properties, the use of <jsp: getProperty> tags.    With <jsp: getProperty> tag, you can specify the name to be used beans (from the id useBean field), and you want to obtain value of the properties.    Then, the real value will be on the output of: <jsp: getProperty id = "localName" property = "name" />. 

  To change the characteristics of JavaBean, you need to use <jsp: setProperty> tags. On the label, you also need to identify the beans as well as the characteristics of that, in addition, you also need to provide a new value. Naming If correct, these can be directly in the format specified by: <jsp: setProperty id = "localName" property = "*" />; 

  Parameters obtained from one, you have to direct this feature, as well as named parameters: <jsp:setProperty id="localName" property="address" param="parameterName" />; 

  Or directly to the name and the value set: <jsp:setProperty id="localName" property="serialNumber" value="string" /> or <jsp: setProperty id = "localName" property = "serialNumber" value = < %% = expression> />. 

  JavaBean the final point: let JavaBean network server can be found, you will need the type of files on the special place.    JSWDK on, the simplest places in the installation directory, the directory of categories, such as \ jswdk-1.0.1 \ classes. 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • DZone
  • Netvouz
  • Propeller

Tags: ,

Releated Java Articles

Comments

Leave a Reply