Tomcat-- profiles, directory structure, etc.

table of Contents


Software architecture

The difference between C / S structure and B / S Structure

Jump to the directory
C / S structure

  • VB, Delphi, VC ++, C #, Java awt / swing: the desktop, such as QQ, mine clearance, Gong Zhu, etc. to run the program desktop .
  • 特点:In the server is mainly a database , all business logic and interface rendering operations to the client to complete.
  • 优点:Security, user interface is very rich, and good user experience.
  • 缺点:Each upgrade will need to be reinstalled for different operating systems development, portability is poor.

B / S structure

  • JSP, ASP, PHP: browser-based application access
  • 特点:The business logic server to complete, just only the client interface rendering and data exchange , B / S are special C / S, this time acting as a client browser based on HTTP protocol.
  • 优点:Only the development of server-side, cross-platform, highly portable and so on.
  • 缺点:Less secure, poor user experience and so on.
  • Responsibilities browser and server
    Here Insert Picture Description
Web resource classification

Go to the directory where
static resources

  • html, css, JavaScript等
  • After all user access, the result is the same, called static resource static resources 直接被浏览器解析.

Dynamic Resource

  • servlet, jsp, php, asp
  • After each user access to the same resources, the result may be different. Called dynamic resource. After the dynamic resource is accessed, it is necessary 先转换为静态资源,在返回给浏览器.
    Here Insert Picture Description
Web server

Go to the directory

  • Role of the Web server receives a client request is made in response to the client.
  • For JavaWeb program only, also need to have JSP/Servlet容器the basic functions of JSP / Servlet container is to 动态资源转换成静态资源, of course, JSP / Servlet container not only these functions.
  • Common Web server software
    web服务器软件中,可以部署web项目,让用户通过浏览器来访问这些项目.

    Tomcat (Apache): currently the most widely used JavaWeb server;
    JBoss (Redhat Red Hat): supports JavaEE applications more widely;
    GlassFish (Orcale): the Oracle development JavaWeb server application is not very wide;
    Resin (Caucho): Support JavaEE , more and more widely;
    Weblogic (Orcale): for money! Supports JavaEE, suitable for large-scale projects;
    Websphere (IBM): for money! Supports JavaEE, suitable for large-scale projects;


Tomcat

Go to the directory

  • Introduction
    Tomcat is a small and medium JavaEE server Apache IMF development, open source is free, Tomcat is a common free web server, Tomcat is written in Java of a server (program), to run Tomcat, 必须得有JRE;

  • Installation, configuration environment variable
    reference this blog: https://blog.csdn.net/qq_40881680/article/details/83582484

  • Access Tomcat
    http://服务器所在主机的IP:服务器的端口号/资源名字.
    注意: access the local IP address of 127.0.0.1 or localhost

  • Directory Structure

    • bin:This directory is stored in binary executable file, if the installed version, then there will be two exe files in this directory: tomcat8.exe、tomcat8w.exethe former is to start Tomcat in the console, the pop-up window UGI start Tomcat; if it is decompressed version then there will be startup.bat和shutdown.bata file, startup.bat used to start Tomcat, but you need to configure JAVA_HOMEthe environment variable to start, shutdawn.bat to stop Tomcat;
    • conf:This is a very important directory, there are four of the most important in this directory 配置文件.

    server.xml:The entire server configuration information. For example, modify the port number, add web hosting;
    tomcat-users.xml:storage tomcat user files stored here is tomcat user name and password, and the user's role information. You can add a comment by pressing the information in the file tomcat user, then you can enter the Tomcat Manager page in the Tomcat home page;
    web.xml:deployment descriptor file, which is registered in many MIME types, namely the document type. The MIME type is the type of documentation between the client and server, such as the user requests a html page, the server will tell the client browser response document is text / html type, which is a MIME type. The client browser knows how to handle it through this MIME type. Of course, this is a html file in a browser. But if the server response is an exe file, the browser can not display it, but download window should pop fishes. MIME is used to describe the content of the document is what type!
    context.xml:Unified configuration for all applications, generally we do not go to configure it.

    • lib:Store dependency jar files Tomcat software starts running.
    • logs:This directory is the log file records the information Tomcat startup and shutdown, there is an error when you start Tomcat, then an exception will be recorded in the log file.
    • temp:Temporary files Tomcat, the things in this directory can be deleted after stopping Tomcat!
    • webapps:Storage directory web projects, where each project is a folder; if this directory already exists a directory, then all that comes with tomcat project. Where ROOT is a special project in the address bar is not given project directory, ROOT is the corresponding project. http: // localhost: 8080 / examples, enter the sample project. Examples of which is the project name, ie the name of the folder.
    • work:Working directory to store the translated Servlet jsp of java bytecode files and documents.
  • FAQ
    Skip to Content

  1. No start Tomcat or Tomcat fails to start, went to visit the address.
  2. Tomcat started successfully, but the appearance 404of the page.
    Perhaps we own the resource wrong path, their own tests, such as a visit to a page that does not exist.
  3. Tomcat has not been shut down, restart Tomcat again.
    Appear: java.net.BindException: Address already in use: JVM_Bind exception.
    Description port being used by another program and the program.
    注意:After the error, to get used to view the log information.Tomcat根/logs/catalina.2015-12-31.log
    Here Insert Picture Description
  4. To ensure the same XML content encoding and file encoding, if Chinese, 建议使用UTF-8, or can not use Chinese.
  5. Start error
    1. Violence: find the port number occupied, and find the corresponding process, kill
      * netstat -ano
      2. tender: modify its port number
      * conf / server.xml
      * <Connector Port = "8888" Protocol = "HTTP / 1.1 "connectionTimeout =" 20000 "
      redirectPort =" 8445 "/>
      * the default port number of the general will is 80.80 tomcat port number is the default port number for http protocol.
      * Benefits: When you visit, do not enter the port number
  • Common Configuration
    1, 修改Tomcat的默认端口:the default port 8080, the default port for the HTTP protocol is 80.
    • Enter the root Tomcat / conf / server.xml file found
    • The default is the first 70 lines, port attribute Connector elements:
    • Configured as port 80 (port 80 is the default port http protocol):
      http://baidu.com:80/index.php equivalent to
      http://baidu.com/index.php
    • Restart Tomcat, see the results;

JavaWeb application directory structure

Go to the directory

  • WEB application refers to a program for browser access, often also referred to as web applications.
    • A plurality of web applications 静态web资源and 动态web资源components.

First, create a static applications

  • Create a directory (such as hello) in the Tomcat webapps directory folder
  • Create a static resource in webapps \ hello \ under (html, js, etc.) index.html
  • Start Tomcat
  • Open a browser to accesshttp://localhost:8080/hello/index.html

Second, create a dynamic application

  • Create a directory under webapps hello1
  • Creating WEB-INF directory in the webapps \ hello1 \ under
  • Creating web.xml in webapps \ hello1 \ WEB-INF \ under
  • Index.html created in webapps \ hello1 \ under
  • Open a browser to accesshttp://localhost:8080/hello/index.html
    Here Insert Picture Description
  • hello: application directory, hello is the name of the application;
  • index.html: application resources. Under application can have multiple resources, such as css, js, html, jsp, etc., can also put resources into folders, for example: hello \ html \ index.html, then access the URL is: http: // localhost: 8080 / hello / html / index.html;
  • WEB-INF:This directory name must be capitalized, something in this directory can not be accessed directly through the browser, something that is put here to be safe .
  • web.xml: deployment descriptor file for the application, can be applied in the configuration file.
  • classes: storage directory class files.
  • lib: storage directory of a jar.

JavaWeb deployment project

Jump to catalog
a direct project can be placed in the webapps directory

  • / Hello: access path of the project -> Virtual Directory
  • Simplify deployment: the project package labeled as a war, then war pack is placed under the webapps directory.
    war package will automatically unzip

Second, the configuration conf / server.xml file

  • In the Hosttag configuration vivo
    <Context docBase="C:\hello" path="/zy" />
    • path: Specifies the current name of the application (virtual directory)
    • docBase: Specifies the physical location of the application
    • Browser access path:http://localhost:8080/zy/index.html
      Here Insert Picture Description

Third, in the conf \ Catalina \ localhost create xml file any name

  • For example abc.xml written in the file
    <Context docBase="C:\hello" />at this time on the path to the virtual directoryxml文件的名称
  • access http://localhost/abc/index.html
Published 149 original articles · won praise 68 · views 120 000 +

Guess you like

Origin blog.csdn.net/m0_37989980/article/details/103862389