Graduation thesis-large-scale WEB Application Development

Source: Internet
Author: User

【Abstract]
JAVA is currently the most popular programming language for large-scale WEB application development on the Internet. This article describes the characteristics of JAVA and JSP technologies and their usage on the Internet, this article introduces the important programming methods of these two technologies and the relationship between them, and completes an online bookstore system based on this technology.
[Keyword] JAVA, JavaBeans, Servlet, JSP, network programming, e-commerce, online bookstore
Abstract
At present JAVA is the hottest programming language for WEB development, This text described the characteristics of JAVA and JSP technology and the state of operating on the Internet, it introduced the relationship between them and the important programming method of the double technology, And work out an online bookstore system base on this kind of technology.
Keywords: JAVA, JavaBeans, Servlet, JSP, web program, internet, bookshop
Contents
1. JAVA Network functions and Programming
1-1 JAVA Introduction
1-2 network application of JAVA
1-3 foundation of JSP-Servlet Technology
1-4 JavaBeans Technology
2. JSP technology Overview
2-1 configure the JSP running environment on Windows
2-2 Comparison of JSP, ASP, and PHP technologies
2-3 JSP syntax Basics
2-3-1 embed HTML files in JAVA
2-3-2 request, out & response -- interaction with visitors
2-3-3 session -- maintain the visitor's session Status
2-3-4 other basic built-in JSP objects
2-4 main methods for developing Web applications using JSP
2-4-1 use JSP directly
2-4-2 JSP + JavaBeans
2-4-3 JSP + JavaBeans + Servlet
2-5 advanced functions implemented by JSP + JavaBeans
2-5-1 access the database with JSP
2-5-2 use JSP + JavaBeans to upload files
2-6 jsp mvc development model
3. Analysis of online bookstore system design project requirements
3-1 Online Bookstore System Model
3-2 online bookstore system database creation
4. Online Bookstore System Development
4-1 Background Management
4-1-1 administrator login
4-1-2 manage book categories
4-1-3 manage book products
4-1-4 registered member management
4-1-5 book subscription Management
4-2 online bookstore Interface
4-2-1 Book Search
4-2-2 view book details
4-3 online shopping program
4-3-1 user registration
Implementation of 4-3-2 shopping baskets
5. Summary
Chapter 1 network functions and programming of JAVA
1-1 JAVA Introduction
Java is an easy-to-use, fully object-oriented, platform-independent, secure, and reliable development tool for the Internet. Since its official launch in 1995, the rapid development of Java has dramatically changed the entire Web world. In the early days, Java was widely used in browsers and inserted into webpages (that is, Java Applet), which became the most flexible and powerful Web Multimedia carrier, however, Java Virtual Machine (VM) has many disadvantages such as resource occupation and poor security compared with personal computers, and Applet is gradually replaced by Flash, but with the introduction of Java Servlet, java has begun to emerge in e-commerce. The introduction of the latest JSP (Java Server Page) technology makes Java the preferred development tool for Web-based applications, currently, Java technology has become an inevitable choice for all large-scale e-commerce projects.
1-2 network application of JAVA
Java programs can obtain images, sounds, HTML documents, texts, and other resources of nodes on the network, and process the obtained resources. For example, a Java program can read the latest data provided by a node at a certain time and display it as a chart. In programming, it is generally a URL-type object, and then the corresponding method in Java is used to obtain the resources represented by this object. The following describes a Java method for obtaining images from the network.
Java Applet can directly obtain and display images from nodes on the network. Java provides the following methods to create images corresponding to other nodes:
GetImage (new URL (string ))
The format can be either of the following:
String url = "Node URL ";
Image image;
Try {
Image = getImage (new URL (url ));
}
Catch (Exception e ){
System. out. println ("Can't open the URL");
}
Or
URL imgur = null;
Image image;
Try {
Imgur = new URL ("Node URL");
}
Catch (MalformedURLException e ){
System. out. println ("Can't open the URL");
}
Image = getImage (imgur );
The previous format uses "new URL (url)" to generate a URL object and directly serves as a getImage parameter. The latter format uses "new URL (url)" to generate a URL object, the two formats are essentially the same. The following is a complete instance (img. java ):
Import java. applet .*;
Import java.net .*;
Import java. awt .*;
Public class img extends Applet {
Image image;
Public void init (){
String url = "http://images.sohu.com/logo1.gif.pdf ";
Try {
Image = getImage (new URL (url ));
} Catch (Exception e ){}
}
Public void paint (Graphics g ){
G. drawImage (image, 0, 0, this );
}
}
Save the above program as an img. java disk, execute javac img. java, the img. class generated after compilation will be obtained, and finally create and call the two Java libraries ):
The above are only some aspects of Java's client application. Currently, Java is more widely used on the server. This is the main topic of this article, the Servlet, JSP, and other technologies mentioned below are specific Java applications on the server.
1-3 foundation of JSP-Servlet Technology
Java Servlet is the foundation of JSP technology. JSP itself is compiled into Servlet in advance and then run. In addition, the development of large-scale Web applications requires the cooperation of Java Servlet and JSP, the Servlet name is probably derived from the Applet. There are many translation methods in China. To avoid misunderstanding, This article uses the Servlet name directly without any translation, it can be called a "small service program ". Servlet actually works the same as traditional CGI programs and Web development tools such as ISAPI and NSAPI. After using Java Servlet, you no longer need to use the inefficient CGI method, you do not have to dynamically generate Web pages using APIs that can only be run on a fixed Web server platform. Many Web servers support servlets. Even Web servers that do not directly support servlets can support servlets through additional application servers and modules. Benefiting from the cross-platform features of Java, Servlet is platform-independent. In fact, as long as it complies with Java Servlet specifications, Servlet is completely platform-independent and Web server-independent. Java Servlet provides services in a thread mode, so you do not have to start a process for each request, and the multi-threaded mechanism can be used to serve multiple requests at the same time. Therefore, Java Servlet is highly efficient. However, Java Servlet does not have any disadvantages. It is the same as the traditional CGI, ISAPI, and NSAPI methods. Java Servlet uses HTML statements to output dynamic web pages, if Java Servlet is used to develop the entire website, the integration of dynamic and static pages is a nightmare. This is why SUN has to launch Java Server Pages.
1-4 JavaBeans Technology
What is JavaBeans? JavaBeans is Java's reusable component technology. ASP expands complex functions through COM, such as file uploading, sending emails, and separating business processing or complex computing into independent Reusable Modules. JSP implements the same function expansion through JavaBeans. JSP provides comprehensive support for the integration of JavaBeans components in Web applications. This support not only shortens the development time (you can directly use tested and trusted existing components to avoid repeated development), but also brings more scalability to JSP applications. The JavaBeans component can be used to execute complex computing tasks, interact with databases, and extract data. In the actual JSP development process, readers will find that compared with the traditional ASP or PHP pages, JSP pages will be very simple, because the JavaBeans development is simple, the powerful functions of the Java language can also be used, and many dynamic page processing processes are actually encapsulated in the JavaBeans.
Chapter 2 Introduction to JSP Technology
2-1 configure the JSP running environment on Windows
To enable the system to run JSP and related programs properly, you must first configure the WEB server that can use JSP. Among the various WEB servers that can use Servlet technology, the most used is the Tomcat server. If it is only for testing programs, Tomcat configuration is too complicated, this article recommends using the Resin server. Resin is said to be the fastest Servlet running platform, but limited to a single site, it does not provide good support for some traditional gateways. Therefore, it is not the best choice for commercial websites, however, if you only want to test the Servlet, the installation of this Resin is a bit silly.
The latest version of Resin is 3.x, but there are many actual 2.x versions. You can download Resin from the official site: External
If JDK has been installed on your computer, decompress the downloaded resin package to the D: root directory and decompress the Package D: \ resin-2.1.13 to the server directory, put the jspweb folder of the source program in this article in the D: disk root directory, that is, D: \ jspweb is the website root directory, open D: \ resin-2.1.13 \ conf \ resin. conf (a configuration file in XML format), find the doc here and change it to D: \ jspweb, then run D: \ resin-2.1.13 \ bin \ httpd.exe, enter http in the browser: // localhost: 8080/j1.jsp, and you can see "I Am a JSP!" Your Servlet server is successfully configured in this way. To compile the Servlet class, you also need to do the following: \ resin-2.1.13 \ lib is added to the environment variable of CLASSPATH in windows.
2-2 Comparison of JSP, ASP, and PHP technologies
JSP, ASP, and PHP are currently the most popular script technology running on servers on the Internet. JSP can be encapsulated Using JavaBeans technology to achieve business logic. ASP corresponds to COM components, therefore, both of them can be used to develop business logic. PHP is more like a pure script. It is only suitable for General website development and cannot be used as business logic and is named "Person Home Page, this is the most appropriate.
Compared with ASP, JSP has the features of cross-platform, secure, and powerful scalability. However, JSP is more difficult to master than other scripts because it must be proficient in the Java language, for small and medium-sized projects, we need to consider issues such as developers, development speed, and development costs. ASP and PHP are easier to win than JSP in this regard.
It is worth mentioning that ASP is the latest version. NET and the original ASP are completely different in nature. Like JSP, It is a compilation script, which is fully integrated with the powerful Net Framework, perfect support for various Xml applications, not the same as ASP in the past, but both ASP and ASP.. NET, which cannot get rid of the Windows platform itself, which is a fatal disadvantage of ASP.
2-3 JSP syntax Basics
2-3-1 embed HTML files in JAVA
Save the following webpage as: j1.jsp
This becomes the simplest JSP page.
Is to declare that the output file type is text/html, the character encoding is gb2312, the content in JSP indicates some options during JSP compilation or JSP commands for sending header information to the client. The content in JSP is the Java language. If necessary, modify the appropriate settings, javaScript can also be used as a script, but it is rarely used in practical applications.
2-3-2 request, out & response -- interaction with visitors
Receiving client requests and returning information to the client are the most common tasks of dynamic web pages. In JSP, these functions are mainly implemented through three objects: request, response, and out.
The request object is used to receive the user's request information and some information related to the user's computer from the sending server through a URL or form.
The response object is used to send a response from a webpage to the client.
Out is used to send the response output, that is, return information to the client.
Slightly modify the above example:
Save as j2.jsp and enter "http: // localhost: 8080/j1.jps?" in the browser? Msg = I am JSP "to check the effect. Is this the same as j1.jsp? But It outputs the information returned by the client, which is completely different from the former in the sense.
2-3-3 session -- maintain the visitor's session Status
Session status maintenance is a must for Web application developers. There are multiple ways to solve this problem, such as using Cookies, hiding form input fields, or directly attaching status information to a URL. Java Servlet provides a continuous and effective session object between multiple requests. This object allows users to store and extract session state information. JSP also has this object built in.
The most basic usage of a Session is:
Create a session. putValue ("name", "value ");
Obtain the session value session. getValue ("name ");
2-3-4 other basic built-in JSP objects
JSP has nine built-in objects, including:
The pageContext page is managed here.
Content being executed by application Servlet
Configuration Servlet framework
Page JSP page itself
Exception for the error webpage, exceptions not captured
These basic built-in objects are important factors that constitute JSP pages.
2-4 main methods for developing Web applications using JSP
This article is a paid paper with more than 8000 words, including the source code. The price is 300 yuan. Please contact QQ: 2500875 for the full text.
Summary
This article describes some basic knowledge of Java/JSP in WEB applications, and deepen the application of JSP through the online bookstore program. From this article, we can see that the mode of combining JSP with JavaBeans, applications in e-commerce are very flexible, but it is not easy to grasp them. In actual WEB development, there are still many security issues that need to be considered. In addition, e-commerce websites generally use the interface of the online payment platform to communicate in the form of xml server. This article does not focus on these aspects.
Attachment: jspweb.zip contains all source programs mentioned in this article and online bookstore systems.
References:
(1) JSP programming skills/edited by Qinghong computer studio. Beijing: Machinery Industry Press, 2001.1
(2) well-versed in JAVA programming in the JBuilder 3 environment/edited by Reith studio. Beijing: People's post and telecommunications press., 2001.1
(3) In-depth JAVA Servlet network programming. Tsinghua University Press

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.