Apache: Tips and Tricks
Learn how to start and stop Apache Tomcat from the command line in a Windows environment.
Deploying a web application to Apache Tomcat is very straightforward using a WAR (Web ARchive) file. By deploying we mean that we are placing a zipped web application in a location on the file system where Tomcat can make the web page(s) available to the world.
Deploying a web application to Apache Tomcat is very straightforward using a WAR (Web ARchive) file. By deploying we mean that we are placing a zipped web application in a location on the file system where Tomcat can make the web page(s) available to the world.
A Java Server Page, or JSP, program is a crucial part of a Java web application because the JSP will send a response back to the server in the form of a web page. For example, a JSP might display the line items of an order to the browser user. In this topic, you will create a very simple JSP and learn how to run the program at the Tomcat server.
Monitoring the JVM is an important part of administering the Apache Tomcat server. The Tomcat manager provides a quick way to check our server's status by displaying how many HTTP threads are active, the storage allocation in the various memory pools plus other helpful data.
To deploy a web application to Apache Tomcat, you can copy a WAR file to the application base directory, e.g.,
c:/Tomcat8/webapps. This operation of course presupposes we know the application base directory. We could consultserver.xmland look up theHostelement to determine the directory name. A more straightforward approach, though, is to use the Tomcat manager web application.Monitoring the JVM is an important part of administering the Apache Tomcat server. The Tomcat manager provides a quick way to check our server's status by displaying how many HTTP threads are active, the storage allocation in the various memory pools plus other helpful data.
A context path in Apache Tomcat refers to the name of the website as presented by the browser. For example, imagine I tell you to enter "localhost:8080/DemoWebsite/DateJSP.jsp" in your browser. The context path is "DemoWebsite". The term "context" in Tomcat is in fact synonymous with "website". The default context path can be specified if we provide a context file to Tomcat that is given the same name as the website. In this topic, you will learn how to accomplish this important task.
When we copy a WAR file to the application base directory of Apache Tomcat, we usually expect the web application to be deployed. In other words, we expect the website to be immediately available on the World Wide Web. However, this doesn't always have to be the case. The
autoDeplyattribute on theHostelement determines if the web application will be available for access on the internet.To deploy a web application to Apache Tomcat you can copy a WAR file to the application base directory, e.g.,
/var/lib/tomcat7/webapps. This operation of course presupposes we know the application base directory. We could consultserver.xmland look up theHostelement to determine the directory name. A more straightforward approach is to use the Tomcat manager web application.The Apache Tomcat manager web application provides a convenient interface that lists deployed web applications.
In another topic, I discussed how to start one member of a Tomcat cluster. Click here to learn how to cluster in Apache Tomcat (Windows). When you have completed the work in that topic, you will be prepared for this topic. I will show you how to run another Tomcat instance on the same server, or computer.
A Java Server Page, or JSP, program is a crucial part of a Java web application because the JSP will send a response back to the server in the form of a web page. For example, a JSP might display the line items of an order to the browser user. In this topic, you will create a very simple JSP and learn how to run the program at the Tomcat server.
Business web applications rely on databases. Therefore, you will probably be required to make a connection to your relational database during the development of a web application. Java accesses relational databases through JDBC (Java Database Connectivity). As of JDBC 2, the database is represented to Tomcat as a data source. In this topic I will discuss establishing a JDBC connection to a MySQL data source in Tomcat.
After you have started the Apache Tomcat server, a logical question to ask would be: "How do I verify the Tomcat server is operational?" In this topic we will find out!
In a production Tomcat environment, you might have hundreds of web requests per second on a routine basis. With so much volume assaulting your Tomcat server, you'll probably discover that memory resources in one Tomcat JVM (Java Virtual Machine) can become overwhelmed. To help prevent this situation from becoming reality you can place two or more Tomcat servers in a cluster.
One important function of the Apache Tomcat manager web application is to undeploy web applications. In other words, the website will be removed from Tomcat and therefore no longer be available on the World Wide Web.
A context path in Apache Tomcat refers to the name of the website as presented by the browser. For example, imagine I tell you to enter "localhost:8080/DemoWebsite/DateJSP.jsp" in your browser. The context path is "DemoWebsite". The term "context" in Tomcat is in fact synonymous with "website". The default context path can be specified if we provide a context file to Tomcat that is given the same name as the website. In this topic, you will learn how to accomplish this important task.
Developers and administrators alike will refer to Apache Tomcat logs from time for diagnostic and performance data. Tomcat uses a customized implementation of
java.util.loggingcalled JULI (Java Utility Logging Implementation). JULI is very similar to standard Java SE logging, even supporting the same configuration file,logging.properties. In this topic, we'll explore a way to route the Catalina logs to a specific destination and then check out the log contents.In a Tomcat production environment, you might have hundreds of web requests per second on a routine basis. With so much volume assaulting your Tomcat server, you'll probably discover that memory resources in one Tomcat JVM (Java Virtual Machine) can become overwhelmed. To help prevent this situation from becoming reality you can place two or more Tomcat servers in a cluster.
Developers and administrators alike will refer to Apache Tomcat logs from time for diagnostic and performance data. Tomcat uses a customized implementation of
java.util.loggingcalled JULI (Java Utility Logging Implementation). JULI is very similar to standard Java SE logging, even supporting the same configuration file,logging.properties. In this topic, we'll explore a way to route the Catalina logs to a specific destination and then check out the log contents.When we copy a WAR file to the application base directory of Apache Tomcat we usually expect the web application to be deployed. In other words, we expect the web site to be immediately available on the World Wide Web. However, this doesn't always have to be the case. The
autoDeplyattribute on theHostelement determines if the web application will be available for access on the internet.Java Management Extensions (JMX) is a technology that permits applications to expose properties and operations through managed beans, or "MBeans". Tomcat supports JMX and provides numerous MBeans to a consumer program, such as
jconsole, that expose useful properties and operations. But in order to access Tomcat's MBeans we must configure Tomcat to expose the MBeans to consumers.The Apache Tomcat manager web application provides a convenient interface that lists deployed web applications.
Apache Tomcat can be installed and configured for first time use in a straightforward way.
Java Management Extensions (JMX) is a technology that permits applications to expose properties and operations through managed beans, or "MBeans". Tomcat supports JMX and provides numerous MBeans to a consumer program, such as
jconsole, that expose useful properties and operations. But in order to access Tomcat's MBeans we must configure Tomcat to expose the MBeans to consumers.
