Preface
At the beginning of Tomcat 7, Tomcat supports multi-version application deployment. This feature is very good, especially in the production environment. You do not need to restart tomcat to upgrade the application. The upgrade process does not affect your business. The hot upgrade feature can only be achieved by a few top-level commercial middleware.
Parallel deployment of Tomcat
At the beginning of Tomcat 7, you can deploy multiple different versions of Web applications with the same context path at the same time. Currently, only Tomcat Manager can useWar file to deployTo achieve simultaneous deployment of multiple versions. The war package name can only beContext. War
,Context # 2.war,Context #3. War and so on.
When you use http: // localhost: 8080/context for access, the rules are as follows:
If the current request does not contain session information, use the latest war application version.
If the current request has a session, use the war application version corresponding to the session.
If the current request has session information but the corresponding war application version cannot be found, use the latest war application version.
Use instance
As a developer, I developed a web application. A Web application is a war package with an index. jsp in it, which simply executes out. Print ("JSP Hello 1 "). After the project is developed, the Web application is packaged as MyApp ##1.war.
Access http: // localhost: 8080/manager/->Deploy->War file to deploy->Select war file to upload-> select MyApp #1. War-> click deploy
After the upload is successful, you can seeApplications adds a path named MyApp,An application whose version is 1.
Use the Google browser to access http: // localhost: 8080/MyApp/index. jsp. the JSP Hello 1 page is displayed.
As the requirement changes, you need to change the page display to JSP Hello 2.CodeThen, package the web application MyApp ##2.war.
Re-upload. You can see that the application adds an application whose path is MyApp and version is 2.
Use the Google browser to access http: // localhost: 8080/MyApp/index. JSP, you can see that the page displays JSP Hello 1 (because the session information corresponds to the application of version 1, we still access the application of version 1)
Then open the Firefox browser and access http: // localhost: 8080/MyApp/index. jsp. the JSP Hello 2 page is displayed. (because there is no session information, access the latest version of the application)