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"/>

时间: 2024-11-05 13:33:47

About Tomcat!的相关文章

解决myeclipse中tomcat启动报错A configuration error occurred during startup. Please verify the preference field whit the prompt:Cannot connect to VM

原因一:可能是tomcat里面文件不小心被删除了.尝试更换tomcat, 解决步骤:重新下载tomcat并解压.点击windows——> preferences——>tomcat重新配置. 原因二:myeclipse系统自带jdk出问题 解决步骤:重新下载tomcat并解压.点击windows——> preferences——>tomcat——>jdk,配置成你自己的jdk 原因三:由于软件冲突导致的错误 解决步骤: 找到myeclipse.ini文件 加上-Djava.ne

eclipse部署tomcat修改项目访问路径(虚拟路径)

原文参考: http://www.educity.cn/wenda/147993.html http://blog.163.com/java_zf/blog/static/19926038420129240314546/ tomcat部署web项目(eclipse自动部署项目到tomcat,访问URL中不包含部署名) 最近项目中需要把项目部署到tomcat中,并且访问路径中不包含不署名,且想实现Eclipse中的自动部署,扒了好久资料,最终实现了自己的需求,呵呵,如下: 1. 把项目contex

Tomcat启动分析(我们为什么要配置CATALINA_HOME环境变量)

原文:http://www.cnblogs.com/heshan664754022/archive/2013/03/27/2984357.html Tomcat启动分析(我们为什么要配置CATALINA_HOME环境变量) 用文本编辑工具打开用于启动Tomcat的批处理文件startup.bat,仔细阅读.在这个文件中,首先判断CATALINA_HOME环境变量是否为空,如果为空,就将当前目录设为CATALINA_HOME的值.接着判断当前目录下是否存在bin\catalina.bat,如果文件

Tomcat配置远程调试端口(windows、Linux)

当我们需要定位生产环境问题,而日志又不清晰的情况下,我们可以借助Tomcat提供的远程调试,设置如下: // Linxu系统: apach/bin/startup.sh开始处中增加如下内容: declare -x CATALINA_OPTS="-server -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8081" // Windows系统:

windows10上使用一个tomcat部署2个项目

前言:目前想在本机部署2个项目,网上查了之后,写下本篇随笔 1.准备工作 2.操作方法 3.运行2个项目 1.准备工作 2个war包(一个jprss.war和一个jenkins.war) 1个tomcat环境 2.操作方法 第一步:复制tomcat中的webapps文件夹,命名为webapps1和webapps2 第二步:复制tomcat\conf\Catalina文件夹,命名为Catalina1和Catalina2 第三步:修改tomcat中的server.xml文件: 将从<Service

Tomcat JDBC Pool使用说明

Maven依赖 <dependency>   <groupId>org.apache.tomcat</groupId>   <artifactId>tomcat-jdbc</artifactId>   <version>8.5.9</version> </dependency> 最新版本为9.0,推荐使用8.5.9稳定版 常用配置 连接池配置项很多,下面只列出了推荐配置,项目组可根据自身情况进行增减 <b

tomcat启动过程报the JDBC Driver has been forcibly unregistered问题的修复过程

最近两天在整理关于flume的总结文档,没有启动过tomcat.昨天晚上部署启动,发现报了如题的错误,全文如下: 严重: The web application [/oa-deploy] registered the JBDC driver [com.microsoft.sqlserver.jdbc.SQLServerDriver] but failed to unregister it when the web application was stopped. To prevent a mem

eclipse中配置的tomcat 启动正常 但是访问报404错误

问题描述: 在eclipse中配置的Tomcat,启动是正常的,控制台显示启动成功,也没有报任何错误信息,但是访问的时候就报404错误,然后直接在bin目录下启动startup.bat的方式就是正常的.然后就很纳闷,之后在网上搜了下资料,说是Eclipse的配置出了问题. 解决方案: 1.如果Server里的tomcat启动了,需要先停掉.然后再移除添加的项目 2.之后双击server中配置的tomcat服务器,会弹出如下界面. 3.在Server Locations配置中选择第二个选项,use

SpringBoot tomcat

该文的前提是已经可以在控制台运行成功,有些时候想放在tomcat里运行 大致分为如下几步 1.配置文件更改 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <!-- <artifactId>spring-boot-starter</artifactId>-

cmd启动和停止tomcat

首先进入Tomcat安装目录下的bin目录 一. cmd命令启动Tomcat服务器: start.bat 补充:若这样启动了Tomcat服务器,此时再去eclipse里面在该服务器上运行javaweb项目,会报错(端口在使用,因为在eclipse上运行项目的时候会再次启动服务器),因此需要先关闭服务器后再去启动eclipse项目上的tomcat服务器 二.cmd命令停止Tomcat服务器: shutdown.bat