A personal reflection on web development

Source: Internet
Author: User

Tomcat Summary:

Tomcat is an open-source application server that is represented by a simple process like this:

As for the interaction with the browser side, we can write a simple mytomcat to steal the information that the browser sends to Tomcat, with the following code:

 PackageTom;Importjava.net.*;ImportJava.io.*; Public classMytomcat { Public Static voidMain (String args[]) {Try{ServerSocket ss=NewServerSocket (8080); System.out.println ("Sever Startup in 1428ms"); Socket s=ss.accept (); InputStream is=S.getinputstream (); InputStreamReader ISR=NewInputStreamReader (IS); BufferedReader BR=NewBufferedReader (ISR);            System.out.println (Br.readline ());            System.out.println (Br.readline ());            System.out.println (Br.readline ());            System.out.println (Br.readline ());            System.out.println (Br.readline ());            System.out.println (Br.readline ());            System.out.println (Br.readline ());        System.out.println (Br.readline ()); }Catch(Exception e) {} }}

Through the analysis of printing information, we can draw a lot of conclusions, the concept of time stamp is most interesting, access to the browser, will be remembered by the browser, the browser as an unstable connection, each time will be "timestamp" return to the server. If we write a myie ourselves. If you vote on a website, set the string that will be cast, and then change the timestamp every time, you will realize the function of the swipe ticket.

At the same time we write a simple Myie program, you can also cheat Tomcat sent to the browser information. The basic meaning of this information is relative to the sending of information, the code is as follows:

 PackageMyir;Importjava.net.*;ImportJava.io.*; Public classMyie { Public Static voidMain (String args[]) {Try{Socket s=NewSocket ("127.0.0.1", 8080); OutputStream OS=S.getoutputstream (); OutputStreamWriter OSW=Newoutputstreamwriter (OS); PrintWriter PW=NewPrintWriter (OSW,true); Pw.println ("Get/test.html http/1.1"); Pw.println ("Accept: */*"); Pw.println ("ACCEPT-LANGUAGE:ZH-CN"); Pw.println ("User-agent:mozilla/4.0 (compatible; MSIE 8.0; "+" Windows NT 6.1; trident/4.0; SLCC2;. NET CLR 2.0.50727;. NET CLR "+" 3.5.30729;. NET CLR 3.0.30729;. net) "); Pw.println ("Accept: */*"); Pw.println ("Accept: */*"); }   }}

In this way, the whole mechanism of Tomcat is not so hard to understand.

Servelt Summary:

Servlet is a derivative of the Web backend, it is a class in Java, in general, when we run Tomcat, when we have a user access to the browser, Servelt calls the Java CALSS file. Because it is the result of the operation, so in advance design of the page, we do not know what the content will be, so it is often called dynamic page.

Another problem, if there is a user access to the browser, Servelt will have to call a class file, to generate objects, and then call, and then after the JVM deleted, this is obviously inefficient, so the design of the Tomcat developer is,

Previously, the Servelt class was created as an object in memory so that we could call the object directly when the user accesses it.

However, there are two problems in this way, (1) If the number of servelt in a system is too large, there must be some useless or seldom used, generating too much will cause redundancy. (2) When multiple users access servelt at the same time, an object is not enough, it is necessary to use multithreading.

The solution to these two problems is that Servelt will be called the first time when the object is created, so it is very clever to solve the above problems.

XML Overview:

Today's databases are two-dimensional tables that hold data, and XML is stored in a tree-shaped structure, and XML is shared, so that XML can be used as a lightweight database. A medium that implements two different database transports. In the non-database domain, XML can also be used to coordinate the data fusion between different computer languages and different servers.

XML files are responsible for storing data, DTDs and schemas are responsible for constraints, CSS and XSL are responsible for translating into representations, Dom and sax are responsible for parsing, and these techniques are integral to the XML system.

The idea of Dom is to read the contents of XML into memory, which maps the XML's tree structure, which can be accessed by invoking the methods of the members of the object.

A personal reflection on web development

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.