Although you can place a large block of code in a small instruction file, most Java code is a component that can be used repeatedly, called JavaBean. JavaBean is the same as ActiveX control items: they provide known functions and are designed for reuse at any time.
The ¤ an region value can be used through a set of features, which 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 JavaBean to your website.
Suppose that the JavaBean is created before the website is created. The first thing you need to do is to tell the JSP page that it wants to use the JavaBean. This can be done using the <jsp: useBean> label:
<Jsp: useBean id = "localName" class = "com. jguru. Person" scope = "application"/>.
<Jsp: useBean> the tag requires you to identify beans using the id attribute. 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. CATEGORY attribute provides how to find it in various methods. The last component to be found 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 shopping cart.
Once you declare a JavaBean, you can access its features to define it. To obtain a specific value, use the <jsp: getProperty> tag. With the <jsp: getProperty> tag, you can specify the name of the bean to be used (from the id column of useBean) and the value acquisition feature. Then, the real value will be placed in the output:
<Jsp: getProperty id = "localName" property = "name"/>.
To change the features of JavaBean, you must use the <jsp: setProperty> tag. for this label, you also need to identify beans and the features to be corrected. 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 get this from a parameter, you must directly name this feature and the parameter:
<Jsp: setProperty id = "localName" property = "address" param = "parameterName"/>;
Or directly set it by name and value:
<Jsp: setProperty id = "localName" property = "serialNumber" value = "string"/> or <jsp: setProperty id = "localName" property = "serialNumber" value = <% = expression %>/>.
The last point about JavaBean: To enable the network server to find the JavaBean, You need to place their category files in a special location. For JSWDK, the simplest thing is the class directory in the installation directory, such as the jswdk-1.0.1classes.