Servlet and jsp concept Summary

HTTP protocol detailed:

http protocols: Hypertext Transfer Protocol (Hyper Text Transfer Protocol)

Role: standardized data interaction between the browser and the server

HTTP protocol request by:

HTTP1.0:GET  POST  HEAD                 

HTTP1.1 new five: OPTIONS PUT DELETE TRACE CONNECT

GET and POST difference:

-get request mode: data request will be? Splice forms in the request header, insecurity is not requesting entity, http protocol although not specified the size of the requested data, but the browser for URL length is limited, so get request can not carry large amounts of data.

-post request mode: data transmission request URL is not visible in the particular entity data, security of the requesting entity. Data for the amount of data transmitted.

HTTP common response code:

1 ** information server receives the request, the requester needs to continue operation

2 ** successful, the operation was successfully accepted and processed

3 ** redirection request further action is completed

4 ** client error, the request contains a syntax error or could not fulfill the request

5 ** Server Error The server error occurred during processing request

-eg: 200 OK: client request was successful 400 BadRequest: client request syntax error, can not be understood by 401 Unauthorized Server: unauthorized request, the status code must be used 404NotFound together with the WWW-Authenticate header field: the requested resource does not exist 500 InternalServerError: the occurrence of unexpected server error 503 ServerUnavailable: the server is currently unable to process client requests may return to normal after a period of time.

The method can handle the browser request to the service and have doGet and doPost, the former priority

Request Object:

- The server creates a request object to the browser after receiving the request, the object is stored in the data request. Server creates when calling Servlet request object as an argument passed to a method of Servlet eg: service method.

- Request Response object used for data processing in response to the acquired request object, the browser displays the result

- request server servlet is invoked, the method will Servlet passing two arguments request and response, request a data storage request relating to the request, response for the object response.

Forwards the request:

- problem solved: The server browser after receiving the request, only use a Servlet request process, will result in different Servlet, logic code redundancy, Servlet responsibilities are not clear

- Features: a request, the information does not change the address bar

Request Object Scope:

Servlet different data sharing

-request.setAttribute(object name,object value);

-request.getAttribute(object obj)

Scope: Based on the request forwarded a request to share all Servlet

Redirect:

Servlet can not handle the current request, forwarding the request form resulting in duplication of data on the use of redirection

- Use: response.sendRedirect ( "Path")

Features: two requests, the browser address bar information changes, avoid duplicate submission form

Cookie technology:

- browser data storage technology, different requests require the same data, to avoid duplication of data writing request.

Features: Suitable for small amounts of data, key-value pairs, unsafe.

Temporary storage: not set, the session is a timing storage period: the time period is set, is stored in the user's computer

ServletContext objects: to solve the problem of different users to share data, created by the object server, a project only one object

ServletConfig对象:ServletContext对象获取web.xml中的配置信息

Session学习:

-session技术:解决一个用户的不同请求的处理需要使用相同数据

Web.xml文件使用总结:存储项目相关配置信息,保护Servlet,解耦一些数据对程序的依赖

Server.xml文件:

-ajax技术:

解决问题:保留原有页面内容,显示新的响应内容。

-EL表达式和Jstl标签库学习:

El表达式:${expression} 和 []

Jstl标签库是EL表达式的扩展,提升JSP页面逻辑代码的编码效率。

过滤器:对服务器资源进行管理,以及保护Servlet。

监听器:eg:统计网站在线人数

 

发布了17 篇原创文章 · 获赞 0 · 访问量 717

Guess you like

Origin blog.csdn.net/weixin_43100012/article/details/104419109