What is a URL?
Uniform Resource Locator.
The composition of the URL?
HTTP/localhost:8080/news/index.html
Protocol part host IP address: port number (domain name) project resource address
Protocol section: HTTP (Hypertext Transfer Protocol) and HTTPS protocol (secure HTTP protocol)
Project Resource address: Project name + file location
Tomcat Server
Role:
(1) Receiving URL requests
(2) Return data
Directory of Tomcat
Unzip version of Tomcat configuration
Add a system variable named Catalina_home, set the installation directory with the value Tomcat
Tomcat Service startup Detection
(1) Enter the http://localhost: port number in the IE Address bar
(2) page entry to TOMCA launch success page
Start: Startup.bat
Stop: Shutdown.bat
(3) Tomcat is a platform developed by Apache for running Web projects
(4) The Tomcat port number can be modified with the configuration file Server.xml
(5) Part of the URL: protocol://HOST Address [: Port number]/resource Path
Web Project
Structure:
(1) Writing Web application code
(2) package the project into the WebApps directory
(3) Launch and access the Tomcat service
Web Application Architecture
Configure access Pages
Web. xml
<welcome-file-list>
<welcome-file> file name .html</welcome-file>
</welcome=file=list>
Returns 4040 if the file is not found
Jsp
The basic concept of JSP?
A technique for embedding Java code in HTML to dynamically display Web pages
Define properties for an entire page by setting multiple properties inside
Syntax: <% @page Property 1 = "Property Value" Property 2 = "Property value 1, property value 2" ... Property N= "Property value N"%>
Common Properties:
<% @page language= "java" import= "java.util.*,java.text.*" contenetype= "text/html";charset=utf-8%>
Small scripts and expressions for JSPs
<body>
The sum of two numbers results in:
<%
Small script
int numa=4,numb=5;
int result=numa+numb;
%>
<%=result%>//Expression
</body>
(1) Page directive Import if you are importing multiple packages. The middle is separated by commas
(2) Page directive recommended that everyone put contenttype= "Text/html;charset=utf-8"
(3) JSP script <%%> Intermediate Java code must conform to the specifications of our Java code
(4) JSP script output content to browser Out.print
HTML comment:<!--HTML comment--
External comment for JSP: <%--jsp comment--%>
Internal comment in JSP script: <%//single-line comment%>
3 <%/* Multi-line Comment */%>
The syntax for embedding Java code directly in a JSP is: <%java code%>
Output execution structure syntax in JSP: <%=java expression%>
The syntax for declaring a global variable in a JSP is: <%!java code%>
How the JSP works
Web container processing JSP file request takes 3 stages
(1) Translation phase (2) Compile stage (3) Execution phase
1. When the user accesses the JSP through the browser, Tomcat is responsible for translating the JSP into a Java file.
JSP declaration-->java method
A piece of code for the _jspservice method in the JSP script-->java file
A code out.print (expression) for a _jspservce method in a JSP expression-->java file
A section of code Out.write (HTML tags) for _JSPSERVCE methods in normal HTML code-->java files
2. The server then compiles the Java file into a class file
3. Server execution class file
First instantiate the generated Java class
Invokes the _jspservice () method of the instantiated object to output HTML to the browser
4. browser renders HTML data
Dynamic Web Development Basics