SoFunction
Updated on 2025-04-13

Graduation Thesis-Large WEB Application Development

【summary】
JAVA is the most popular programming language used in the development of large-scale WEB applications on the Internet. This article describes the characteristics of JAVA and JSP technologies and their use on the Internet, introduces the important programming methods of these two technologies and the relationship between the two, and completes an online bookstore system based on this technology.
【Keywords】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 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 
Table of contents
1. JAVA's network functions and programming
1-1 Introduction to JAVA language
1-2  The application of JAVA language on the Internet
1-3  The basics of JSP—Servlet technology
1-4 JavaBeans technology
2. Introduction to JSP technology
2-1 Configure the JSP running environment under Windows platform
2-2 Comparison of JSP, ASP and PHP technologies
2-3 JSP syntax basics
2-3-1 HTML file embedded in JAVA language
2-3-2 request, out & response——Interaction with visitors
2-3-3 session--maintain the visitor's session state
2-3-4 Other basic built-in objects of JSP
2-4 Several main ways to develop web applications with JSP
2-4-1 Directly use JSP
2-4-2 JSP + JavaBeans
2-4-3 JSP + JavaBeans + Servlet
2-5 Advanced features implemented by JSP + JavaBeans
2-5-1 Accessing database with JSP
2-5-2 Use JSP + JavaBeans to implement file upload
2-6 JSP's MVC development model
3. Analysis of online bookstore system design project requirements
3-1 Model of the online bookstore system
3-2 Establishment of online bookstore system database
4. Development of online bookstore system
4-1 Backend Management
4-1-1 Administrator login
4-1-2 Book category management
4-1-3 Book Product Management
4-1-4 Registered Member Management
4-1-5 Book Ordering 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
4-3-2 The realization of shopping basket
5. Summary
Chapter 1: JAVA's network functions and programming
1-1 Introduction to JAVA language
Java is a simple and easy to use, completely object-oriented, platform-independent, secure and reliable development tool for the main Internet. Since its official launch in 1995, the rapid development of Java has brought about earth-shaking changes in the entire Web world. In the early days, Java was mostly used in browsers and inserted into web pages (i.e., Java Applet programs), becoming the most flexible and powerful carrier of web multimedia. However, due to the shortcomings of Java virtual machines taking up a large resource and relatively poor security compared to personal computers, Applet was gradually replaced by rising stars Flash. However, with the launch of Java Servlets, Java began to make its debut in e-commerce. The launch of the latest JSP (Java Server Page) technology has made Java the first choice for web-based applications. Current Java technology has become an inevitable choice for all large-scale e-commerce projects.
1-2 Application of JAVA language on the Internet
Java programs can obtain the images, sounds, HTML documents and text of nodes on the network, and can process the obtained resources. For example, Java programs can read the latest data provided by a certain node at a certain time and display it in the form of a chart. In programming processing, it is usually a URL-type object, and then uses the corresponding method in Java to obtain the resources represented by the object. The following lists a method of obtaining images from the network by Java.
Java Applet can directly obtain images from nodes on the network and display them. Java provides the following methods to create images corresponding to other nodes:
getImage(new URL(string))
There are two formats for use:
String url = "Node URL";
Image image;
try {
              image = getImage(new URL(url));

catch(Exception e){
              (“Can't open the URL “);
}
or
       URL imgur=null;
       Image image;
       try {
imgur=new URL("node URL ");
       }
     catch (MalformedURLException e) {
        (“Can't open the URL “);
     }
     image=getImage(imgur);
The former format uses "new URL(url)" to generate a URL object, and directly serves as a parameter of getImage. The latter format uses "new URL(url)" to generate a URL object, and then passes it to getImage. The two formats are essentially the same. The following is a complete example():
       import .*;
       import .*;
       import .*;
       public class img extends Applet{
            Image image;
            public void init() {
                 String  url = “/”;
                 try {
                        image = getImage(new URL(url));
                 }catch(Exception e){}
            }
            public void paint(Graphics g) {
                (image, 0, 0,this);
            }
       }
The program will be uploaded to save it, and the javac will be executed. The compiled HTML document will be created and placed in the same directory. The corresponding HTML document can be as follows ():
The above are only some aspects of Java's client application. At present, Java's wider application is on the server side, which is the main topic of research in this article. The Servlet, JSP and other technologies mentioned below are all specific forms of Java's application on the server side.
1-3 The foundation of JSP—Servlet technology
Java Servlet is the basis of JSP technology. JSP itself is pre-compiled into Servlets and then runs. Moreover, the development of large-scale web applications requires the cooperation of Java Servlets and JSP to complete. The name Servlet probably originated from Applets. There are many translation methods in China. In order to avoid misunderstandings, this article directly uses the name Servlet without any translation. If readers are willing, they can call it a "small service program". Servlets actually have the same function as traditional CGI programs and web program development tools such as ISAPI and NSAPI. After using Java Servlets, users no longer have to use inefficient CGI methods, nor do they have to use API methods that can only run on a fixed web server platform to dynamically generate web pages. Many web servers support Servlets, and even web servers that do not directly support Servlets can support Servlets through additional application servers and modules. Thanks to the cross-platform features of Java, Servlets are also platform-independent. In fact, as long as they comply with the Java Servlet specifications, Servlets are completely platform-independent and Web server-independent. Since Java Servlet provides services in a threaded manner, there is no need to start a process for each request, and multiple requests can be served at the same time using a multi-threading mechanism, Java Servlet is very efficient. But Java Servlet is not without its shortcomings. It is the same as the traditional CGI, ISAPI, and NSAPI methods. Java Servlet uses output HTML statements to implement dynamic web pages. If Java Servlet is used to develop the entire website, the integration process of dynamic parts and static pages is simply a nightmare. This is why SUN also launches 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 upload, email sending, and separating business processing or complex calculations into independent and reusable modules. JSP achieves the same functional expansion through JavaBeans. JSP provides complete support for integrating JavaBeans components in web applications. This support not only reduces development time (can directly utilize tested and trusted existing components to avoid duplicate development), but also brings more scalability to JSP applications. JavaBeans components can be used to perform complex computing tasks, or be responsible for interaction with databases and data extraction. In the actual JSP development process, readers will find that compared with traditional ASP or PHP pages, JSP pages will be very concise. Because JavaBeans is simple to develop and can utilize the powerful functions of the Java language, many dynamic page processing processes are actually encapsulated into JavaBeans.
Chapter 2 Introduction to JSP Technology
2-1 Configure the JSP running environment under the Windows platform
In order for the system to run JSP and related programs normally, it is necessary to configure a WEB server that can use JSP. Among all kinds of WEB servers that can use Servlet technology, the most commonly used is the Tomcat server. If it is only for testing programs, the configuration of Tomcat seems too complicated. This article recommends using a Resin server. Resin is said to be the fastest Servlet running platform, but it is limited to a single site and does not support some traditional gateways. Therefore, it is not the best choice for commercial websites. However, if it is just for testing Servlets, the installation of Resin is a bit foolish.
The newer version of Resin is, but there are currently many versions used. Resin can be downloaded from the official website: /download/This article uses version 2.1.13, and the file location: /download/resin-2.1.
If your computer has JDK installed, directly unzip the downloaded resin package to D: after decompressing the root directory of the disk, D:\resin-2.1.13 is the server directory, and also place the source program jspweb folder of this article, which is D:\jspweb as the website root directory. Open D:\resin-2.1.13\conf\  (it is an XML configuration file), find doc here and change it to D:\jspwee b, then run D:\resin-2.1.13\bin\, enter http://localhost:8080/ in the browser, and you see the words "I am JSP!". Your Servlet server is configured successfully. In order to compile the Servlet class, the other thing you need to do is: add D:\resin-2.1.13\lib to the environment variable of the CLASSPATH of Windows.
2-2 Comparison of JSP, ASP and PHP technologies
JSP, ASP and PHP technologies are both the most popular scripting technologies running on the server side on the Internet. JSP can be encapsulated with JavaBeans technology to achieve the purpose of business logic. ASP corresponds to COM components, so both can be used to develop business logic. PHP is more like a pure script, only suitable for ordinary website development, and cannot be used as business logic and is named "Person Home Page". This is the most appropriate thing.
Compared with ASP, JSP has the characteristics of cross-platform, security, and powerful scalability. If you have to find some problems, JSP is more difficult to master than other scripts, because proficient in JSP must be proficient in Java. For small and medium-sized projects, we need to consider developers, development speed, development cost and other issues. In this regard, ASP and PHP will be easier to win than JSP.
It is worth mentioning that the latest version of ASP is completely different from the original ASP. Like JSP, it is a compiled script. It is completely combined with the powerful Net framework and perfectly supports various applications of Xml. It is incomparable to the ASP in the past. However, neither ASP nor it can get rid of the Windows platform itself, which is a fatal disadvantage of ASP.
2-3 JSP syntax basics
2-3-1 HTML file embedded in JAVA language
Save the following page as:
This becomes the simplest JSP page, which
It declares that the output file type is text/html, and the character encoding is gb2312. The content in JSP represents some options during JSP compilation or JSP instructions that send header information to the client. The content in it is Java language. If necessary, change the appropriate settings and use JavaScript as a script. However, few people do this in actual applications.
2-3-2 request, out & response--interaction with visitors
Receiving client requests and returning information to clients is the most common thing for dynamic web pages. In JSP, these functions are mainly achieved through three major objects: request, response, and out.
The function of the request object is to receive the user sending request information and some information related to the user's computer to the sending server through the URL or through the form.
The response object is used to send a web page back to the user's response.
out  is used to transmit the output of the response, that is, return information to the client.
Make a little modification to the above example:
Save it as input: "http://localhost:8080/?msg=I am JSP" in the browser, let's see the effect, is this the same result? 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 state
Session state maintenance is a problem that web application developers must face. There are a variety of ways to solve this problem, such as using cookies, hidden form input fields, or directly appending status information to the URL. Java Servlet provides a session object that is continuously valid between multiple requests. This object allows users to store and extract session status information, and JSP also has this object built-in.
The most basic usage of Session is:
Create a session ("name", "value");
Gets the value of a session ("name");
2-3-4 Other basic built-in objects of JSP
JSP has nine built-in objects, in addition to the above four, it also includes:
pageContext The properties of the web page are managed here.
Application What is being executed by Servlet
config Servlet's architecture components
page JSP web page itself
exception: For the wrong web page, uncatched exception
These basic built-in objects are important factors that make up JSP pages.
2-4 Several main ways to develop web applications with JSP
This article is a paid paper with a word count greater than 8,000, including source code, and the price is: 300 yuan. Please contact QQ: 2500875 to request the full text.
Summarize
This article talks about some basic knowledge of Java/JSP in WEB application, and deepens the application of JSP through online bookstore programs. From this article, we can see that the combination of JSP and JavaBeans is very flexible in e-commerce, but it is not easy to truly master them well. In actual application of WEB development, there are still many security issues that need to be considered. In addition, the interfaces using online payment platforms in e-commerce websites are generally used to communicate in the form of xml server, and this article has not covered these aspects yet.
Attachment:, contains all the source programs mentioned in this article and the online bookstore system.
References:
(1) JSP programming skills/edited by Qinghong Computer Studio. Beijing: Machinery Industry Press, 2001.1
(2) Proficient in JAVA programming in JBuilder 3 environment/edited by Ruisi Creation Studio. Beijing: People's Posts and Telecommunications Press., 2001.1
(3) Deep in JAVA Servlet network programming. Tsinghua University Press