The 4th lesson of the Java Learning Series--java web-related

Source: Internet
Author: User
Tags gz file apache tomcat

Address of this article

Share an outline:

1. Overview

2. JSP Basics

2.1

1. Overview

1) "Source and pilot"

This article is the main Java Web Tutorial source JSP is the rookie tutorial JSP and the day Code Camp Java Web.

The main pilot source of work is known, please refer to self-learning Java How to get started and how to learn Java Web technology systematically

2) "Brain map"

Java Web Mind Map

2. JSP Basics

  2.1) "Introduction"

JSP full name Java Server pages, is a dynamic web development technology. It uses JSP tags to insert Java code into the HTML Web page. Labels usually end with <% beginning with%>.

JSP is a Java servlet that is primarily used to implement the user interface portion of a Java Web application. Web developers write JSPs by combining HTML code, XHTML code, XML elements, and embedded JSP operations and commands.

2.2) "JSP development Environment Construction"

A) "Configuring the Java Development tool (JDK)"

This is the basic Java environment, before the basic tutorial has been told, here a little. Tutorial for reference to the Java Development Environment configuration section

  

b) "Set up Web server: Tomcat"

Installation and configuration of Tomcat under Mac

Good Installation and configuration of Tomcat under Linux

--"Download Tomcat"

Download the full tar.gz file package for MAC version to the official Apache homepage. Unzip the copy to the/usr/local directory and name Tomcat, and the other directories are available.

--"Modify directory Permissions" sudo chmod 755/usr/local/tomcat/bin/*.sh--"Start tomcat" sudo sh startup.sh
The following prompt indicates that the installation and operation succeeded:
        
--"Browser access" open Browser, enter http://localhost:8080/
If you see Apache Tomcat after carriage return, you have successfully run Tomcat--"modify port is not 8080" vim tomcat/conf/server.xml--use Tomcat to publish a Application http://www.cnblogs.com/xdp-gacl/p/4097608.html--"Routing" a) http://10.x.xx.xx:8080/examples/in dex.html the corresponding file is/usr/local/tomcat/webapps/examples/index.html
b) http://10.x.xx.xx:8080/the corresponding file is/usr/local/tomcat/webapps/root/index.jsp     2.3) "Set up a virtual host, etc." a) Tomcat directory structure
bin//Command script file to store tomcat
conf//Storage of various configuration files for Tomcat server, mostly Server.xml
Lib//store Tomcat Server support Jar package
logs//storing log files
Temp//Storing temporary files
webapps//web application directory, external access to Web Resources storage directory
Working directory of work//tomcat


b) directory structure of Web applications
WebApp--The directory where the Web application resides
|---html, JSP, CSS, JS files, etc.-these files are generally in the root directory of the Web application, the files under the root directory can be directly accessed by the outside world.
|---web-inf directory-java classes, JAR packages, Web configuration files exist in this directory, the outside world is not directly accessible, the WEB server is responsible for the call.
|---Classes Directory--Java class
|---lib directory--the jar package required for Java classes to run
|---web. xml file--configuration file


c) Configuration of the virtual host
Specify the virtual hostname, modify Conf/server.xml, add <context path= "/webapp" docbase= "/webapps/webapp"/>
Cases:
You must set up DNS resolution (host file or DNS system).




d) Mapping of Web applications and virtual directories.
You can modify the <Context> elements of an XML configuration file to set up mappings for Web apps and virtual directories.
conf/server.xml//Add <context path= "/webdir" docbase= "/webappdir"/&gt under the conf/context.xml//Add <Context> elements All Web apps are valid.
Conf/[enginename]/[hostname]/context.xml.default//[enginename] is generally Catalina, and all Web applications of the host [hostname] are valid.
conf/[enginename]/[hostname]///Create a file (extension XML) in the directory, and the file name is the virtual directory name. The multi-level directory uses # segmentation. <context docbase= "/webappdir"/>
The default Web App catalog can be defined as Root.xml, add <context docbase= "/webappdir"/&gt, and restart the Tomcat server.
· Meta-inf/context.xml//
The Web application can be placed in the WebApps directory for the Tomcat server to automatically map, suitable for the development environment, the actual use of the environment without automatic mapping.
If the configuration file is not modified, the Web App directory is the default Web app when it is rooted.


e) configuration of the Web Application home page (welcome file)
To modify a WEB app's configuration file: [Webapp]/web-inf/web.xml
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

The 4th lesson of the Java Learning Series--java web-related

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.