Introduction to Java Web


Main concepts in Web Development
1. Static resources: unchangeable. html、js、css
2. Dynamic resource: Java Web. Output or generate static resources. (the page users see in the browser is always a static resource)
3. Java EE: a collection of thirteen technologies. JSP / servlet is one of them.
Container: (server). Support what technology server, referred to as XX container.

Heavyweight and lightweight servers: depending on the number of services supported.

How to distinguish the technology of javase and JavaEE? java.***JavaSE    javax.**   JavaEE


The server

2、Tomcat6.0   Servlet/ JSP:2.5/2.1     JDK:1.5 (starting from Tomcat 6.0, only JRE is OK)

   Tomcat7.0   Servlet/JSP:3.0/2.2    JDK:1.6


Tomcat installation and problem solving
1. Unzip to a directory or disk (please do not unzip to the Chinese directory or the directory with spaces)
2. Enter the Tomcat / bin directory and execute the startup.bat Start Tomcat
3. Access with browser http://localhost : 8080 /, if you see the interface, the installation is successful!

1. Flash by
2、JAVA_ Home environment variable

Solution: configure the system environment variable Java_ HOME=”C:\jdk1.6.0_ 20″

Tip:Catalina_ The home environment variable is not recommended

3. Port occupied: the default port used by Tomcat is 8080.
Change the default port number of Tomcat: find Tomcat / conf\ server.xml , search 8080, change to own port (not occupied by others)

The default port number of HTTP protocol is 80.— > :80

Tomcat directory structure (specified by the server manufacturer)
bin:Tomcat Start and stop scripts for
Conf: store the configuration file of Tomcat. *. properties or *. XML
Lib: store the jar package that Tomcat depends on.
Logs: store Tomcat running logs.
Temp: store temporary files
Webapps: stores web applications managed by Tomcat. There are several folders in this directory, which means that Tomcat manages several applications.
Work: This is the working directory of Tomcat.

Standard directory structure of Java Web
Myapp: (APP name)
1. HTML, 1. JS and so on
WEB-INF: must have, and the name must be consistent. (the file resources stored in this directory cannot be accessed directly by users)
Lib: store the jar package serving this application
web.mxl : must have. The configuration file for the current application.
Classes: it has to be. Store the class that serves the current application. com.itheima.SomeClass .     classes\com\itheima\ SomeClass.class

What’s the difference between Lib in Tomcat and jar in lib of Java Web application?
Lib in Tomcat is a Tomcat service, which is shared by all managed Java Web applications.
The Lib of Java Web application only serves itself.

Loading order of duplicate classes: loading order of class loader
Classes in my application — jar in Lib in my application — class file in Tomcat / lib — jar in Tomcat / lib — not found, classnotfoundexception

How to deploy Java Web application to Tomcat
1. Open directory deployment: directly copy the application to Tomcat.
2. Make the application a war package. Enter the application directory and execute Jar – CVF MyApp.war .
Copy the war package to Tomcat / webapps, and the container will decompress the application automatically.

The core components of Tomcat
a. Virtual directory mapping: mapping the real directory on the local disk to a virtual directory for external access
C: (itheima / heima15 / day03) information (myapp) – > / myapp
server.xml : context element. Configure an app
Method 1: (not recommended, need to restart Tomcat)
In the < host > element, add the following contents: < context path = / myapp “docbase =” C: / / itheima / heima15 / day03 / myapp “/ >
Path: virtual directory. Start with ‘/’
Docbase: real directory. (Chinese catalogue is not good)
Method 2:
Create a configuration file with XML extension in Tomcat \ [enginename] \ [host name] \ \ directory.
The file name is the name of the virtual directory. Add the following configuration to it:
<?xml version=”1.0″?>
<Context docBase=”C:\ITHEIMA\heima15\day03\MyApp”/>

Small experiment: configure default port, default application and default page
http://localhost Time —— > C: itheima / heima15 / day03 / myapp / 1.html
Default port: modify server.xml Change 8080 to 80
Default application: (all need to be restarted) create a directory named ROOT.xml Configuration file for.
<?xml version=”1.0″?>
<Context docBase=”C:\ITHEIMA\heima15\day03\MyApp”/>
Default home page: modify the web.xml , add the following:
<?xml version=”1.0″ encoding=”ISO-8859-1″?>

<web-app xmlns=””
b. Virtual host
to configure server.xml Host element in
<Host name=””  appBase=”c:\itcastapps”/>
Name: website name
Appbase: the directory where all applications of this website are stored.

Domain name resolution: you can modify the file C: windows, system32, drivers, etc. hosts in the windows system to map the domain name and IP (change back to the original 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; authoritative digital certificate authority.
To create a self signed digital certificate:
Keytool in JDK can create the certificate.
keytool.exe -genkey -alias ppp -keyalg RSA
The generated certificate is stored in the folder of the current login user by default.

Recommended Today

Review of SQL Sever basic command

catalogue preface Installation of virtual machine Commands and operations Basic command syntax Case sensitive SQL keyword and function name Column and Index Names alias Too long to see? Space Database connection Connection of SSMS Connection of command line Database operation establish delete constraint integrity constraint Common constraints NOT NULL UNIQUE PRIMARY KEY FOREIGN KEY DEFAULT […]