Java basic exercises-write a server using basic knowledge

basic knowledge

  • XML, HTML
  • Object-oriented
  • String、StringBuilder
  • Multithreading
  • SAX XML reading
  • reflection
  • Singleton mode

Realize function

  • Encapsulate Request to realize the function of forwarding and obtaining parameters
  • Encapsulate Response to implement simple external web page redirection
  • Custom server port, error page, welcome page
  • Declare Servlet and ServletMapping in the prescribed format
  • Support GET method to pass parameters
  • Support POST URLencoded form data method to pass parameters

Realization idea

Project structure diagram

Insert picture description here
The implementation is relatively long. If you are interested, please see the implementation ideas of Java basic-blank server.
This article looks at the implementation effect

Show results

Use default port, default error page, default welcome page, service without servlet

Insert picture description here

Use configuration files to customize ports, custom error pages, custom welcome pages, and servlet-free services

Insert picture description here

Test Servlet forwarding function

Insert picture description here

Test Servlet redirection function

Insert picture description here

Multi-parameter acquisition test

Insert picture description here

Simple login function to test parameter acquisition and forwarding function according to the request method

Insert picture description here

Code acquisition

GitHub code hosting If you
are interested, you can take a look. Any bugs are purely normal.

Guess you like

Origin blog.csdn.net/L333333333/article/details/104345671