Main concepts in Web Development
1. Static resources: static resources. Html, js, css
2. Dynamic Resources: JavaWeb. Outputs or generates static resources. (The pages you see in your browser are always static resources)
3. JavaEE: a collection of technologies in 13th. JSP/Servlet is one of them.
Container: (server ). What technology does the server support? XX container for short.
Heavyweight and lightweight servers: determine the number of services supported.
Tip:
How can we differentiate JavaSE and JavaEE technologies? Java. *** JavaSE javax. ** JavaEE
Server
1. http://www.apache.org
2. Tomcat6.0 Servlet/JSP: 2.5/2.1 JDK: 1.5 (since Tomcat6.0, only JRE is supported)
Tomcat7.0 Servlet/JSP: 3.0/2.2 JDK: 1.6
Tomcat installation and troubleshooting
1. decompress the package to a directory or disk (do not decompress it to a Chinese directory or a directory with spaces)
2. Go to the Tomcat \ bin directory and run startup. bat to start Tomcat.
3. Access http: // localhost: 8080/in a browser. If you see the interface, the installation is successful!
Problem:
1. Flashing
2. JAVA_HOME Environment Variables
Solution: configure the system environment variable JAVA_HOME = "C: \ jdk1.6.0 _ 20"
Tip: The Catalina_home environment variable is not recommended.
3. Port occupied: Tomcat uses port 8080 by default.
Change the default port number of Tomcat: Find Tomcat \ conf \ server. xml, search for 8080, and change it to your own port (not occupied by others)
Tip:
The default port number for HTTP is 80. Http://www.jb51.net ---> http://www.jb51.net: 80
Tomcat directory structure (defined by the server vendor)
Tomcat:
Bin: Tomcat startup and stop scripts
Conf: stores the Tomcat configuration file. *. Properties or *. xml
Lib: stores jar packages that Tomcat depends on.
Logs: stores Tomcat running logs.
Temp: stores temporary files
Webapps: stores Web applications managed by Tomcat. This directory contains several folders, which indicates that Tomcat manages several applications.
Work: This is the working directory of Tomcat.
Standard directory structure of JavaWeb (defined by SUN and standardized)
MyApp: (Application name)
1. html, 1. js, and other resources
A
1. html
WEB-INF: must have and must have the same name. (The file resources stored in this directory cannot be directly accessed by the user)
Lib: The jar package for storing and serving this application
Web. mxl: required. The configuration file for the current application.
Classes: required. Class for the current application. Com. itheima. SomeClass. classes \ com \ itheima \ SomeClass. class
Tip:
What is the difference between lib in Tomcat and jar in lib of Java Web application?
The lib in Tomcat is the Tomcat service and is shared by all managed Java Web applications.
Java Web application lib, only for your own service.
Loading Sequence of cognominal classes: loading sequence of class loaders
Classes in your own application ---> jar in lib in your own application ----> class file in Tomcat \ lib ----> jar in Tomcat \ lib is not found, ClassNotFoundException
How to deploy a JavaWeb application to Tomcat
1. Open Directory deployment: directly copy the application to Tomcat.
2. Pack the application into a war package. Go to the application directory and run jar-cvf MyApp. war.
Copy the war package to Tomcat \ webapps. The Container automatically decompress the application.
Core Components of Tomcat
A. virtual directory ing: maps the real directories on the local disk into a virtual directory for external access.
C: \ ITHEIMA \ heima15 \ day03 \ \ MyApp ----->/MyApp
Server. xml: Context element. Configure an application
Method 1: (not recommended. You need to restart Tomcat)
Add the following content to the <Host> element: <Context path = "/MyApp" docBase = "C: \ ITHEIMA \ heima15 \ day03 \ MyApp"/>
Path: virtual directory. Starting "/"
DocBase: Real directory. (The Chinese directory does not work)
Method 2:
Create a configuration file with the xml extension in the Tomcat \ [enginename] \ [hostname] \ directory.
The file name is the name of the virtual directory. Add the following Configuration:
<? Xml version = "1.0"?>
<Context docBase = "C: \ ITHEIMA \ heima15 \ day03 \ MyApp"/>
Lab: configure the default port, default application, and default page
Http: // when localhost is used ------> C: \ ITHEIMA \ heima15 \ day03 \ MyApp \ 1.html
Default port: Modify server. xml to change 8080 to 80
Default Application: (restart required) create a configuration file named ROOT. xml in the Tomcat \ [enginename] \ [hostname] \ directory.
<? Xml version = "1.0"?>
<Context docBase = "C: \ ITHEIMA \ heima15 \ day03 \ MyApp"/>
Default homepage: modify web. xml in the application and add the following content:
<? Xml version = "1.0" encoding = "ISO-8859-1"?>
<Web-app xmlns = "http://java.sun.com/xml/ns/javaee"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
Version = "2.5">
<Welcome-file-list>
<Welcome-file> index.html </welcome-file>
<Welcome-file> 1.html </welcome-file>
<Welcome-file> index. jsp </welcome-file>
</Welcome-file-list>
</Web-app>
B. VM
Configure the Host element in server. xml
<Host name = "www.itcast.cn" appBase = "c: \ itcastapps"/>
Name: website name
AppBase: the directory that stores all applications on the website.
Domain name resolution: you can modify the C: \ WINDOWS \ system32 \ drivers \ etc \ hosts file in the widows system to map the domain name and IP address (change it to its original state after playing)
C. connector: SSL
HTTPS = HTTP + SSL. The default port is 443. Tomcat: 8443.
SSL: Data Encryption (asymmetric encryption) + identity authentication (Digital Certificate)
Certificate Authority, CA; VeriSign; Thawte; an authoritative Digital Certificate Authority.
Create a self-Signed digital certificate:
The keytool in JDK can create this certificate.
Keytool.exe-genkey-alias ppp-keyalg RSA
The generated certificate is stored in the folder of the current logon user by default.