Although you can put a large block in a small instruction file Program Code But most Java program code is a reusable component called JavaBean. Like ActiveX controls, JavaBean provides known functions and is designed for reuse at any time.
The value of Javabean is that it can be used through a set of features that provide access to the JavaBean settings. For example, this person is a JavaBean, and his name, Social Welfare Security number, and address can be characteristic. For JSP websites, you basically dynamically connect 'java' to your website.
Suppose that Javabean is created before the website is created. The first thing you need to do is to tell the JSP page that it needs to Use Javabean. this can be done by using the <JSP: usebean> volume label: <JSP: usebean id = "localname" class = "com. jguru. person "Scope =" application "/>.
<JSP: usebean> you must use the ID attribute to identify beans. here, you provide a name for the JSP webpage to identify beans. In addition to the ID attribute, you must also tell the webpage where to find the beans, or its Java category name. The category attribute provides how to locate it in various methods. The last required component is the scope attribute. with the help of the range attribute, You Can Tell Beans to ask for a single webpage (preset) [scope = "page"]; for a requested webpage [scope = "request"]; for the call period [scope = "session"]; or [scope = "application"] for the entire application to maintain its own information. for the call period range, you can easily maintain items on the JSP page, such as the shopping cart.
Once you declare a JavaBean, you can access its features to define it. To obtain a specific value, use the <JSP: getproperty> volume tag. With the <JSP: getproperty> label, you can specify the name of the bean to be used (from the ID field of usebean) and the value acquisition feature. Then, the real value is placed in the output: <JSP: getproperty id = "localname" property = "name"/>.
To change the JavaBean feature, you need to use the <JSP: setproperty> volume label. you also need to identify beans and the features to be corrected for this scale. In addition, you need to provide new values. if the name is correct, these can be obtained directly in the specified format: <JSP: setproperty id = "localname" property = "*"/>;
To obtain a parameter, you must directly name this feature and the parameter: <JSP: setproperty id = "localname" property = "Address" Param = "parametername"/>;
Or directly set the parameter by name and value: <JSP: setproperty id = "localname" property = "serialnumber" value = "string"/> or <JSP: setproperty id = "localname" property = "serialnumber" value = <% = expression %>/>.
Last point about JavaBean: To enable the network server to find JavaBean, you need to put their category files in a special location. For jswdk, the simplest thing is the class directory in the installation directory, such as \ jswdk-1.0.1 \ Classes.