• About Tomcat!


    Tomcat is a free server.

    The detail of Tomcat directory structure:

      bin --> include some batch file and jar file. For example : the start and shutdown command settled in this folder

      conf --> many configuration file located here such as server.xml and web.xml

      lib --> the necessary jar files are included : servlet-api.jar, jsp-api.jar. So we can make the conclusion: Tomcat server support Servlet and JSP.

      logs --> there're some log files

      temp --> when you upload a picture or some other file , the file will be put in this folder

      webapps --> this is the most important folder. We can see that all of our applications are put here and there are much information in its child folder:

        WEB-INF --> the WEB-INF won't be modified because some key files are put here, if they can be changed easily , it's not a secure choice.

          classes --> the classes file whilch related to the application are put here.

          lib --> the jar file will be built path automatically in this folder

          web.xml --> this is the key configuration file which could connect the class file with the server.In the main body part:

            <servlet>

              <servlet-name></servlet-name>  

              <servlet-class></servlet-class>

            </servlet>

            <servlet-mapping>

              <servlet-name></servlet-name>

              <url-pattern></url-pattern>

            </servlet-mapping>

          These two tags could be very useful.

      work --> the app has runned before will be put here , if you find your server starts at a low speed , you can make a clearance of this folder.

    Also , there is a very important method to create a war file:

      Run the cmd and go to the app's directory via command.

      Then you should input :

        jar  -cvf myapp.war .

      to create the war file.

      You'll find the war file in the webapp folder.But why should we create the war file?

      You can assume the occasion, if you run your code at your customer, there maybe doesn't have myEclipse or IntelliJ. Once you have you war file in your 

    hand, you should only copy the file and the Tomcat will create the folder automatically which also will relate the class file . It's really convenient.

    To use the Tomcat more flexible , we can use the virtual path:

      Open the server.xml in the config folder.

      Add the tag: <Context path="/appsw" docBase="e:/myapp"/> then save and close the server.xml.

      The next step you should do is to execute the shutdown.bat and restart the Tomcat server.

      You can use the url : http://localhost:8080/appsw/1.html

      We can see that the appsw represent the path : e:/myapp

    But there remains a disastrous problem: we can see that if we want to use the virual path , we must close the server and restart it.

    If there're many users are using our application, this behavior will lead to break down.So use the external file to set the Context is very necessary.

    So to slove it ,we can see the Tomcat's index.html:

      Configuration --> Context --> Defining a context --> The second method

      The context path is the file's name.And you only need to set the Context's docBase attribute : <Context docBase="e:/myapp"/>

    Where does the resource of web application located in the Tomcat server?

       

  • 相关阅读:
    【转】:java遍历List时动态添加和删除元素
    【转】:浅析 Comparable和 Comparator的区别
    【转】:Synchronized同步静态方法和非静态方法总结
    【转】:学习路线(自用)
    js原型链的理解
    关于浏览器切换标签或者移动端切换应用时,js不执行的解决方案
    .net core连接mongoDB
    首先从项目结构开始讲起
    iOS应用内支付(IAP)服务端端校验详解
    .net支付宝SDK接入这些坑你必须知道
  • 原文地址:https://www.cnblogs.com/ppcoder/p/7171939.html
Copyright © 2020-2023  润新知