The more you want to build the superstructure, the more you feel the underlying foundation is important. Lesson series.
Book is a conscience book, is too basic, is suitable for making up a lesson.
"Text Version"
Tomcat and the Java Web
Development Technology Detailed
Servlet
The life cycle of the servlet
Initialization
1Servlet Container loading servlet class
2Servlet container Create ServletConfig, initialize configuration information
3Servlet Container Creation Servlet Object
4Servlet container calls the Servlet object's init (servletconfig)
Opportunity: First requested or configured <load-on-startup>
Run-time
Receive requests encapsulate ServletRequest and Servletresponse
Call Service ()
Generating response results from Servletresponse
Destroyed
Call Destroy ()
Destroying a Servlet object
Destroy the corresponding ServletConfig
Context of the app Serletcontext
A webapp corresponds to a serletcontext
Monitoring Interface Servletcontextlistener
Contextinitialized (servletcontextevent)
Contextdestroyed (servletcontextevent)
The life cycle of httpsession
Create
The first time the browser accesses the app
The last session of the browser was destroyed, but the app is accessed again
Browser access without the last session ID
Destroyed
Server Call Invalidate ()
Session Expiration
The server cannot directly know that the browser is terminated
Setmaxinactiveinterval (int)
Function range
Request.getsession ()
The session data can be shared as long as it can be taken to the conversation object
Listener interface for the session
Configuration in Web. xml
Httpsessionlistener Monitoring creation and destruction
Httpsessionattributelistener Monitoring Property changes
Depositing sessions as attribute objects
Httpsessionbindinglistener the binding of the Listener property
Httpsessionactivationlistener listening session activation and shelving
Filter filters
Call in series in sequence in Web. xml
Chain.dofilter () recursive invocation
Call relationship is Filter1->filter2->...->servlet
Thereafter the return is filter1<-filter2<-... <-servlet
Req and resp packaging for Servletrequestwrapper and Servletresponsewrapper
Xml
Load order
ServletContext (Context-parm)->listener->filter->servlet
Other (slightly)
Tomcat
Three modes of operation
Standalone
Jvm->tomcat->servlet container
Other server process content device (JNI)
Tomcat is divided into Web plugin and servlet container two parts
The JVM that the container component runs inside the other server
The Web plugin is also in this server
The Web plugin invokes the container component through JNI
Other server out-of-process containers (IPC)
Tomcat is divided into Web plugin and servlet container two parts
Container components run in standalone JVM
Server does not need to support servlet
Web plug-in runs on the server
The Web plugin calls the container component through the IPC
Server.xml
Server, Service, Engine, Host (abbreviated)
Context
ClassName: Can specify an implementation class
Path: URL entry for the app
DocBase: File path for the app
Reloadable: Automatic monitoring of updates and reloading (but increased running load)
Cookies: Allow a cookie to support the session
Usenaming: Support Jndi
Manager Session Manager
Default Standardmanager
A class package that can be joined to memcached for centralized session management
Cluster cluster
Engine to add <Cluster> and configure Deltamanager (or other implementations)
Enable <distributable/> in the app's Web. xml
Properties to be stored in session to implement the serialization interface
Network Environment Support Multicast
Connector
Listening port
AJP protocol
Configure SSL
JK Connectors
Access Tomcat through the AJP protocol
As plug-ins can be integrated in servers such as Apache,iis
Relm Security Domain
Enabling authentication at the Tomcat level
There are different implementations of configuration files, JDBC, DataSource, etc.
Valve Valves
Engine, host, and context three range of functions
The implementation of Tomcat's own band
Customer Access Log Valve
Remote Address Filter
Remote host Filter
Customer Request Recorder
SSI (Server Side Include)
Often used for web-page stitching, such as headers and footer
Just a few simple instructions.
Realized in the form of Ssiservlet
of Web applications
Several invocation methods
Ejb
Java EE application structure
Customer tier (browser or client)
Web layer (JSP and servlet)
Business Layer (EJB)
Session bean-Logic
Have status
No status
Entity bean-entity
EIS layer (database)
Interface
Remote Interface Ejbobject
Home interface EJBHome
The Bean class implements the Sessionbean and implements the remote interface concretely.
Technology stack
Server: JBoss
Invocation method: RMI
Soap
WebService
SOAP: Data exchange protocol based on XML language
WSDL: Web Service Description Language based on XML language
Communication protocols
Http/https
Smtp/pop3
Invocation mode
Rpc
message-oriented
Technology stack
Web Services Framework: Apache AXIS
Server: Tomcat
MVC pattern
Level
Model: Business logic
Views: User Rendering
Controller
Receiving user requests
Call model to respond to user requests
Select View to display response results
Advantages: 3 modules are independent, loosely coupled
JSP Model 2
Servlet as Controller
JavaBean as a model
JSP as a view
Struts
Implementing the MVC Web framework
Controller
Filterdispatcher+struts.xml forward the request to the respective action
The action class focuses on the process of the control program
Velocity
The role of template language: Separating Java code from a Web page
Use of the engine
Servlet class Inheritance Velocityservlet
Overriding the HandleRequest method
Storing variables in the context object
Returns the specified template file
Extracurricular supplement: Several ways of remote communication
RPC: Remote Procedure Call
TCP connections
Application-layer Addressing (such as the URI address of HTTP)
Serialization and deserialization of requests and responses
RMI Remote Method invocation
Java language only
Strong objects
WebService
HTTP connection
SOAP protocol
Based on XML
RESTful style
Resource-oriented get/post/put/delete operations
(often using JSON-based data exchange)
Jms
Java Messaging Service
JSP and Jstl (slightly)
"Tomcat and Java Web Development technology detailed" mind map