Js
JSP and javabean
Although you can put a large chunk of program code in a small instruction file, most Java program code belongs to reusable components called JavaBean. JavaBean are like ActiveX controls: They provide known functionality and are designed to be reusable for any purpose. The value of the
JavaBean is that it can be used through a set of attributes that provide access to JavaBean settings. As an example, the person is JavaBean, and his name, social security number, and address can be characteristic. For JSP sites, basically you are ' JavaBean ' dynamically connected to your site.  &NBSP
Suppose JavaBean is built before the site is built, the first thing you need to do is tell the JSP page what it needs to use JavaBean. This work can be done with <jsp:useBean> labels:< Jsp:usebean id= "LocalName" class= "Com.jguru.Person" scope= "Application" />. The
<jsp:useBean> label requires you to identify beans with the id attribute. Here, you provide a name for the JSP page to identify the beans, in addition to the id attribute, you must also tell the page where to find the beans, Or it's the Java category name. The category attribute provides a way to find it in a variety of ways, and the last component required is the scope property. With the help of the range attribute, you can tell the beans to have it for a single page (preset) [scope= "page"]; for a requested web page [scope=] Request "], for the duration of the call [scope=" session "], or for the entire application [scope=" Application "] to maintain its own information. For the duration of the call, you can easily maintain the items in the JSP page, such as the shopping cart. &NBSP;&NBSP
Once you have declared JavaBean, you can access its features to fix it. To obtain the value of an attribute, use the <jsp:getProperty> volume label. With the <jsp:getProperty> label, you can specify the name of the bean to use (from the Usebean ID field), and you want toGets the attribute of the value. The real value is then placed in the output: <jsp:getproperty id= "LocalName" property= "name" &NBSP;/>.&NBSP;&NBSP;
To change the characteristics of the JavaBean, you need to use the <jsp:setProperty> volume label. You also need to identify the beans and the features to be corrected for this label, but you also need to provide new values. If the name is correct, these can be obtained directly through the prescribed format:< Jsp:setproperty id= "LocalName" property= "*" />; &NBSP;&NBSP
to be obtained from one parameter, you must directly name this attribute as well as the parameters: <jsp:setproperty id= "LocalName" property= " Address " param=" ParameterName />; &NBSP;&NBSP
or set directly by name and value: <jsp:setproperty id= "LocalName" property= "SerialNumber" value= "string" /> or <jsp:setproperty id= "LocalName" property= " SerialNumber "&NBSP;VALUE=&NBSP;<%=&NBSP;EXPRESSION&NBSP;%>&NBSP;/>.&NBSP;&NBSP
The last point about JavaBean: to get the Web server to find JavaBean, you need to put their category files in a special location. The simplest place for JSWDK is the category directory in the installation directory, such as jswdk-1.0.1classes.
The internal object of the JSP
The last component associated with the JSP syntax is called an internal object. Within the JSP small instruction file, you can access these internal objects to interact with the servlet environment that performs JSP Web pages. Many of the access to internal objects should be simplified. However, these are examples, their access is acceptable, and the need for a complete use of internal object settings requires an understanding of the latest JAVA&NBSP;SERVLET&NBSP;API. &NBSP;&NBSP
The following table lists the internal objects you can use. &NBSP;&NBSP
Internal Object Description
request client request, this request contains parameter from Get/post request;
Response Web page Returns the response of the client
pagecontext Web page properties are here to manage
session The session associated with the request &NBSP;&NBSP
Application servlet The content being executed
out The output stream used to transmit the response The
Config servlet's schema object the
Page JSP web page itself
Exception for error pages, and not catch exceptions &NBSP;&N Bsp
So, what do these do, and how do you use them? Basically, in your small instruction file, you can use them to access the servlet that executes the JSP program code. To avoid talking too much about servlet api , let's examine some of the things you can do with them:
You don't have to use an expression. You can directly access the internal out object to print something to response:
<% out.println ("Hello");
You do not have to send parameters directly to JavaBean, you can fetch them by requesting objectsThe value of the parameter:
<% string name=request.getparameter ("name"); out.println (name); %>. &NBSP;&NBSP
After you have written many applications in JSP, if you build a JavaBeans or find yourself putting too many Java primitives into your JSP files, you need to build a supported Java class, This encourages reuse and reduces the time that is required for JSP Web pages to be converted. When you need to build a Java class, you must: &NBSP;&NBSP
Adds the JDSWK installation directory in directory to your path. At the end of the path to your Autoexec.bat file, join c:1.2.2in; . &NBSP;&NBSP
Copies the jar file to the Jrelibext directory with the following instruction:
copy c:jswdk-1.0.1libservlet.jar C:jdk1.2.2jrelibext.