JSP + Javabean step-by-step tutorial (1)

zhaozj2021-02-12  133

JSP Javabean step-by-step tutorial (1) Source Java

[中文 JAVA Technology Network 2002-04-24]

JSP has been more and more widely used as a good dynamic website development language. In various JSP applications, JSP Java Beans has become a standard for the most common JSP programs, let us Take a look at how the specific JSP is combined with Java Bean. This tutorial will explain the principles of JavaBean, then explain the JavaBean's specific grammar under the JavaServer Page, then demonstrate a simple counter using JSP JavaBean, and finally explain a user registration program for JavaBean JSP with database functions. Java bean principle and application 1, what is Javabean? JavaBean is a software component model describing Java, a bit similar to Microsoft COM component concept. In the Java model, the JavaBean can be expanded to the Java program, which can quickly generate new applications through JavaBean combination. For programmers, the best thing is that JavaBean can realize the reuse of code, and there is also a significant significance for the easy maintenance of the program. JavaBean can get the correct execution through Java Virtual Machine, running JavaBean minimal demand is a version of JDK1.1 or above. JavaBean traditional applications are visual fields, such as Applications under AWT. Since JSP is born, Javabean is more applicable in non-visual fields, which exhibits more and more powerful vitality in server-side applications. Here we focus on non-visualized Javabean, visualized JavaBean has many Java books on the market, and there is a detailed explanation, here is not a focus. 2. Non-visualized JavaBean non-visual Javabean, as the name implies is JavaBean without a GUI interface. In the JSP program, it is often used to encapsulate transaction logic, database operations, etc., which can achieve the separation of business logic and foreground programs such as JSP files, so that the system has better robustness and flexibility. A simple example, such as a shopping cart program, to implement a function of adding a commodity in the shopping cart, you can write a shopping cart operation JavaBean, build a public AddItem member method, directly call this in front desk JSP file Method is realized. If you need to judge whether there is goods after adding items, no goods can be purchased, at this time we can directly modify the JavaBean AddItem method, join the processing statement to implement, so you don't have to modify the front desk JSP program. Of course, these processing operations can also be written fully in the JSP program, but such a JSP page may have hundreds of thousands of lines, and the light-looking code is a headache, and it is not necessary to modify it. If you have used the ASP development process, I believe that it is deeply experienced? The bench bench split SP COM components can achieve the same architecture as JSP Javabean, but I don't know how to write all the online common writies. In the ASP page, it is extremely inconvenient to maintain maintenance modification, of course, this is an external version). It can be seen that the logical package can be achieved with JavaBean, and the programs are easy to maintain. If you use a JSP development program, a good habit is to use more JavaBean. 3, Javabean's simple example to create javabean is not a difficult thing. If you write the Java program, it is easy. Pay attention to a member method that is common> get or> set in non-visual Javabean. To process properties> (Properties>).

转载请注明原文地址:https://www.9cbs.com/read-6454.html

New Post(0)