Design and implementation of automatic generation tool based on JSP Web page

Source: Internet
Author: User
Tags define definition extend functions html tags new features version microsoft iis
js| Design | Web page

Absrtact: Web Development technology is an important aspect of Internet application, and JSP is the most advanced technology of web development, which is the first technology of Web developers. However, because JSP requires a high level of web developers, many general Web developers are not able to use this advanced technology. This paper discusses the design and implementation of JSP Web page automatic generation tool based on template and tag library, and puts forward the concrete design idea and realization method.

Keywords: JSP; automatic generation; web development; tags; tag library; template

Directory:

The introduction of ...... ..... ..... ..... ..... ...... ..... ... ............. ...... ....... ....... ... 2
1 System design objectives and the use of the main technology ......... ... 4.............
1. 1 design goals .............. .......... ................. ........ 4
1. 2 main techniques ... ............. .......... ................. ........ 4
1. 2. 1 template technology .............. ....... ............... ........ 4
1. 2. 2 Tag Library technology ........... ......... ... 4. ........................
2 The composition and implementation of the system ...... .......... ............... ........ 6
2. 1 The system is composed of ....... ....... ...... ..... ................. ........ 6
2. 2 The realization of the system ... ............. ..... ................ ........ 7
2. 2. 1 Template Library and the implementation of the tag Library ............ ... 7............
2. 2. 2 system development environment ...................................... ... 11
3 Concluding remarks ... ..... ........ ....... ....... ... .............. ....... ....... ... 11

Introduction

With the popularization of WWW (World Wide Web), Dynamic Web page technology is developing rapidly. From the original CGI (Common Gateway in-terface) to the ASP (Active Server page), to some extent, the Web developers to meet the needs of dynamic web development technology. However, whether CGI or ASP have some limitations, such as the cost of CGI to server resources, ASP can only use with Microsoft IIS, etc., which limit the use of these technologies, and greatly hinder their promotion. The vast number of page developers are eagerly looking forward to a unified page development technology that should feature: ① is independent of the operating platform and can be run on any Web or application server; ② separates application logic from page display; ③ provides code reuse, Simplifies the process of developing web-based interactive applications.

JSP (Java Server Page) technology is designed to meet this requirement. JSP is a new Web development technology launched by Sun Microsystem Company in June 1999, it is a web development technology based on Java Serv-let and the whole Java system, it is Servlet2. 1API of expansion. With this technology, we can build advanced, secure and Cross-platform Dynamic Web sites.

Java is the future mainstream development technology, has many advantages. JSP is the Java on the Internet/intranet Web important application technology, has been widely supported and recognized, it can and a variety of Java technology in good combination, so as to achieve very complex applications.

As a text-based, display-centric development technology, JSP provides all the benefits of the Java servlet. To make logical and display functions separate, JSPs can already work with JavaBeans, Enterprise JavaBeans (EJB), and servlet. JSP developers can do most of the work related to the Web site by using JavaBeans, EJBs, and servlet, and simply hand the work of the display to the JSP page. The advantage of separating content from display logic is that people who update the appearance of the page do not have to understand Java code, and the person who updates the Java class does not have to be an expert at designing Web pages. This allows you to define a Web Template with a JSP page with Java classes to create a Web site with a similar look. Java classes do provide data, and there is no Java code in the template, which means that the templates can be maintained by an HTML writer.

As the current mainstream web page development technology, JSP has the following characteristics.

1 Separation of content generation and display: Using JSP technology, Web page developers can use HTML or XML identities to design and format the final page. Use a JSP logo or a little script to generate dynamic content on the page (content varies according to request). The logic for generating content is encapsulated in identity and JavaBeans components, and bundled in small scripts, all scripts run on the server side. If the core logic is encapsulated in logos and JavaBeans, then others, such as Web managers and page designers, can edit and use JSP pages without affecting the generation of content.

2) Emphasize reusable components: Most JSP pages rely on reusable, cross-platform components to complete the more complex processing required by the application. Thanks to Java's operational platform independence, developers can easily share and communicate components that perform common operations, or make these components available to more users. The component-based approach accelerates the overall development process and greatly enhances the overall development efficiency of the project.

Although JSP is powerful, it requires web developers to be quite familiar with Java. And now the Java programmer is still relatively few, for the general Web page developers, JSP syntax is more difficult to grasp. Therefore, it is necessary to have a web development tool, for the general Web page developers to provide common JSP applications, so that only understand the General page Development Technology (HTML) developers can also use the powerful functions of JSP.

1 System design objectives and the main technology used

1. 1 Design goals

The design goal of this system is to provide a web development tool for general Web developers who only know HTML but have no knowledge of JSP, so that they can use JSP's common functions according to system documents, and finally generate a dynamic JSP page containing only static HTML and JSP tags.

1. 2 Main Technical

The system in the design, mainly consider the use of templates and JSP tag technology to achieve.

1. 2. 1 Template Technology

Template technology is widely used in various development and application systems. It generates some commonly used framework structure, so that users can easily select templates from Template Library according to their own needs, instead of rebuilding themselves, which saves the user's development time and facilitates the user's use. In this system, the page is classified according to the function type, the common page type is summed up, and the template library is generated.

1. 2. 2 Tag Library Technology

In JSP, actions are elements that can create and Access program language objects and affect the output stream. The JSP defines six standard actions. In addition to these six standard actions, users can define their own actions to perform specific functions. These actions are called custom actions, and they are reusable program modules. Through these actions, the programmer can in the JSP page the page display function also partially encapsulates, make the whole page more concise and easy to maintain. In a JSP page, these customized actions are invoked through a custom label. The tag library is a collection of customized tags.

The JSP tag library is a way to generate xml-based scripts through JavaBeans. It is one of the biggest features of JSP. Through the tag library, can extend the JSP application indefinitely, complete any complex application requirements.

The JSP tag Library has the following characteristics.

1 Easy to use: the tags in the JSP and the general HTML tags are exactly the same in appearance, and are as convenient to use as normal HTML tags.

2 Easy Code reuse: Tag Library of each tag can complete a certain function. Once you have defined a tag library, you only need to wrap the tag library into a jar file, so you can use the tag library on other systems later, instead of developing the code, it greatly improves the system development efficiency and reduces the development cost.

3 Easy Code Maintenance: All the application logic is encapsulated in the label processor and JavaBeans, all the tags are in a tag library. If you need to update your code or you need to modify the functionality on a Web page, you need to modify the corresponding label. This kind of unified maintenance way, does not need to make the modification on each webpage, greatly reduces the maintenance the workload, saves the maintenance cost.

4 Easy System Expansion: If you need to add new features to the system, you need to define a new tag to complete this function, without any changes to the other aspects of the system. Tag libraries can inherit the features of the JSP specification. This allows you to extend and increase the functionality of the JSP indefinitely without waiting for the next version of the JSP to appear.

2 The composition and implementation of the system

2. 1 System composition

The system is mainly composed of four parts.

1 Database connection: This system supports several commonly used databases, including Oracle, Sybase, MSSQLSERVER, MySQL, and DB2, which are connected to the database according to the user-selected database type and user-supplied database name, username, and password using JDBC.

2 System base table Generation section: After the database connection, based on the user name connected to the database to generate two system base table Tc-tables and Tc-columns,tc-tables table contains all the tables in the database of the user's English name, Chinese name and some attributes, If it can be modified, whether it can be queried, and so on; The Tc-columns table contains the Chinese and English names and other properties for all columns in all the tables in the database that belong to that user. such as whether it can be displayed, whether it can be queried. These two system basic tables provide basic information about the database used by users throughout the system development process.

3 template selection and Web page Generation section: This part is the core of the system. It contains two sub modules.

① template selection: The system provides the user with a template selection interface, allowing the user to select the template to use from the template Library as needed.

② template Processing Section: Based on the user-selected template, the system calls the specified template processing module to process the template. When the handler encounters a label in the template, it provides the user with an interactive interface, allows the user to enter parameters for the specified label, and verifies the validity of the user-entered label by the system. Finally, the system completes the JSP page generation.

4 Page Preview and modify part: The Web page generated after the system to provide users with a Web Page Preview window and Code View Modify window. Through this preview window, the user can preview the results of the generated JSP page. If the user is not satisfied with the static aspect of the page, the user can modify the HTML code in the code by looking at the modification window. If the user to the static effect of the page further requirements, the system also provides users with a call to the Dreamweaver editor interface, users can use it to generate the JSP page static effect of further modification and improvement.

2. 2 implementation of the system

2. 2. 1 The implementation of Template Library and tag Library

The planning and design of tag library is very important in the whole system design, which relates to the degree of code reuse and the efficiency of system operation. Its planning should follow the following principles.

1 in the label should be as little as possible contain static HTML. For the average user, the label is transparent. Users are not able to view and modify labels. If the label contains too many static HT-ML statements, will affect the user's static effect on the page to modify and improve, limit the use of labels.

2) Try to improve the reuse of code. In the JSP application classification is as far as possible to the common JSP application extraction, form a label. Instead of implementing the application repeatedly in each label. So in the future to modify and improve the application, just to modify the label, easy to maintain the code.

3 convenient for the use of users. When designing a tag library, you should take full account of the user's usage and make it easy and convenient for users to understand and use labels.

① Label Library definition: Define a tag library, you must first define a tag library description file (TLD). This is an xml-based script file, in this file, you define the version of the XML, the encoding used, the version of the tag library, the version of the JSP used, the name of the tag library, and the definition and parameter descriptions of all the tags contained in this library, including the name of the tag, the Java class that the tag corresponds to, The description information of the label.

Implementation of the ② tag: a tag is a special Java

Class, this class must inherit the TagSupport class, which is in javax. Servlet jsp defined in the Tagext package. In the tag class, the parameter initialization method (Set/get) of the label, the principal processing method (Handler) of the label, and the method for the next level of tag invocation are included.

Implementation of the ③ template: A template is a JSP file that contains a label reference. In order to reference the defined label in the template, you must first introduce the tag library.

<%@taglib uri= "tag. TLD "prefix=" Ctag "%>

Where the URI specifies the path to the tag library description file; prefix specifies the prefix to use when referencing the label.

When a specified label is referenced in a template, the name of the label is specified using the prefix specified when the tag library is introduced, and the label's parameter is assigned a value.

2. 2. 2 System development Environment

This system main program development uses is Borland Company's JBuilder 6. 0, the template development use is Microsoft Company's front-page2000, the tag library development uses the UltraEdit editor, the JDK uses the JDK1. 4. The system test environment is JRUN3. 0.

3 concluding remarks

Java is the mainstream of future development languages, and the main application of Java on the Web JSP will become the mainstream of future web development technology. This system uses the JSP one of the biggest characteristics of the tag library, so that the general Web developers can easily use JSP powerful dynamic page function, the development of technologically advanced JSP Dynamic Web page. Because the system is developed in the Java language, it can be run under any operating system that supports a graphical interface, which is completely unrelated to the platform. This system is easy to expand and perfect. In the future can be considered to provide users with interface, so that users can expand their own template Library and tag library, further enhance the system's functionality.

Reference documents

[1] Cay S. Horstmann,gary Cornell. Java 2 Core Technology (Corejava 2) [M]. Beijing: Machinery Industry Press.
[2] Bruce Eckel. Java Programming Idea (thinking in Java) [M]. Beijing: Machinery Industry Press.
[3] Joseph L.. Weber. Java 2 Programming details (Using java 2) [M]. Beijing: Electronic industry publishing house.
[4] Borland company. Building Applications with JBuilder.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.