How to install and configure Apache Tomcat Server


I know that all you have successfully installed Java into your machines. In this blog I am using Apache Tomcat server as default web server in JSP. Here you can see how to install Apache Tomcat server into your machine.

How to Install Apache Tomcat server


In these days latest version of Apache Tomcat is 8.0.8  You can download the latest version on following link. http://tomcat.apache.org/download-80.cgi

Then you can download the file that you want to install in your machine. I am using Windows 8.1 64bit Operating system. Then I downloaded the following marked file.


How to Configure Apache Tomcat server

Set JAVA_HOME

First of all you need to create JAVA_HOME environment variable. You can do it like we did when installing java into your machine. You need to provide JDK installed directory for the variable value. (C:\Program Files\Java\jdk1.8.0_05).

Then you have to configure the server. You may have downloaded zip file now. You have to unzip and save it on any directory you like. (try to use simple path like D: or E:)

Then you need to change some settings to work on it. Go to to the apache-tomcat-8.0.8 and config folder. Then you will be able to see four XML pages.

Configure server.xml file

This is used to set the TCP port numbers. Find following code and change the port number between 1024 to 65535 skipping assigned port numbers in your machine(Open cmd and type netstat -a to check your port numbers in windows). Default port number is 8080 for Apache tomcat server.




Configure web.xml file

change the code as follows. 


Configure context.xml file

You need to add attribute to context tag as follows.


Configure tomcat-users.xml file

This is used to setup username and password of the user of Apache server. Do it as follows. I use root as the username and 1234 as the password.


Then you are totally configured to use Apache Tomcat Server. Then you need to start the server.

How to start the server ?

  • Go to Command Prompt.
  • Go to the directory that you have saved Apache Tomcat Server.
  • Locate the bin folder.
  • I have saved my server in D directory. Look at my cmd. 

  • Now I am in bin folder.
  • Then type startup and enter to execute.
  • Then you will see some changes in cmd and another window like CMD called Tomcat.



Now you successfully started Apache Tomcat server. You can go to your browser and type localhost:port_number to open home page of Apache Tomcat server.

Ex: localhost:8080



How to shutdown the server ?


Type shutdown in cmd and enter.


Where to save your projects ?

In Apache Tomcat folder, you can see a folder called webapps. You can save your projects in this folder. You can create your own folders in this webapps folder.

How to run your jsp files ?


I have created folder called "JSP" in webapps folder. Within this folder I have saved JSP file called "test.jsp". This is the way that you can access to this jsp file. 

                                  http://localhost:8080/JSP/test.jsp

Save following code as your first JSP program and run it to see your IP address.

<html>
<head>
<title>JPS test</title>
</head>
<body>

<%

 out.print("Your IP address " + request.getRemoteAddr());

%>

</body>
</html>








How to install and configure Apache Tomcat Server How to install and configure Apache Tomcat Server Reviewed by Ravi Yasas on 11:08 PM Rating: 5

No comments:

Powered by Blogger.