Do you know what is Web Application?
- If Yes, you must be aware about Web Server, Am I right? E.g. Tomcat, JBoss, etc.
Tomcat is a Open Source (Yes you heard it right) Web server by the Apache Software Foundation. It implements Java EE specifications such as JavaServer Pages (JSP), Java EL, Java Servlet, and WebSocket.
- Why we need to use Tomcat?
We can use tomcat to provide a “pure Java” Runtime Environment or HTTP web server environment for Java code to run in.
- How to Download Apache Tomcat 9 on Windows 10?
Before we start we need to ensure that JRE / JDK is installed on machine. The simplest way to check for java is execute java command in command prompt. If it says external or internal command not found, in that case we need to install JDK first. To download JDK, http://www.oracle.com/technetwork/java/javase/downloads/index.html. Download appropriate JDK for tomcat. For tomcat 9 recommended JDK is 8 or later. Refer http://tomcat.apache.org/whichversion.html.
Once the JDK is installed next steps is to download Tomcat, which can be downloaded from apache tomcat site https://tomcat.apache.org/download-90.cgi. To directly download exe click Tomcat9.exe .
Click on the apache-tomcat-9.0.0.M3.exe that will open Welcome to the Apache Tomcat Setup Wizard, Click on Next.
Click on “I Agree” on the License Agreement (As if you are going to click on Cancel-Pun Intended)
On the next scree, we can choose features or components we want to install. Host Manager and Examples are not selected by default. In our case we will select it and click on Next.
Here, we have a golden chance to customize basic configuration related to Port, Windows Service Name, and Tomcat Administrator Login. Please note Tomcat Administrator Username, Password, Roles (admin-gui,manager-gui); we will verify how it is used and where it is configured later in the post. Click on Next.
Configure Java Virtual Machine or JVM Path here. We have to select Java SE 7.0 or Later JRE to install Apache Tomcat 9. Click on Next.
Here is a complicated decision to select Install Location (Just Kidding). Click on Next…NO, here we need to click on Install 🙂
Verify the Installation process, it may take 1-2 minutes. Click on Next.
Click on Finish once Apache Tomcat Installation Wizard in completed..
Immediately, Service Manager will start a Apache Tomcat 9.0 Tomcat 9 Service.
Verify the status of Windows Service in the Taskbar.
Verify Display Name, Service Name, Startup Type – Here it is manual. We can Start, Stop, Pause, or Restart Service from the same dialog box.
To change the Startup type, click on the List box and select “Automatic”.
Click on the Java and Logging Tabs to verify respective settings currently available. Click on Ok.
Open any Browser and navigate to http://localhost:8080. It will open a Home Page
Verify Installation Directory of Apache Tomcat 9. In our case, It will be C:Program FilesApache Software FoundationTomcat 9.0
To Verify Manager Application Installation, Click on the Manager App Link available on Tomcat Home Page. Now, It will open a Dialog box for User Name and Password.
Tomcat Administrator Username, Password, Roles (admin-gui,manager-gui)? Give User name and Password configured earlier and click Ok.
It will Open a Manager Application at http://localhost:8080/manager/html
Now go to Windows Explorer and open C:Program FilesApache Software FoundationTomcat 9.0conf
Edit tomcat-users.xml and verify the content:
<user username=”admin” password=”*********” roles=”admin-gui,manager-gui” />
Visit Example Link from Tomcat Home Page: http://localhost:8080/examples/
To know and see Servlet Example visit http://localhost:8080/examples/servlets/
Right click on Execute Link of Hello World Servlet and Click Open in new tab.
Click on the Source Link available on http://localhost:8080/examples/servlets/ to get a feel about Servlet Code.
Similarly, navigate to http://localhost:8080/examples/jsp/
Click on Execute link of JSP 2.0 Expression Language – Basic Arithmetic – http://localhost:8080/examples/jsp/jsp2/el/basic-arithmetic.jsp
Verify the source code at http://localhost:8080/examples/jsp/jsp2/el/basic-arithmetic.jsp.html