Installing, Configuring, & Running Tomcat 6.0 Servlet Container on Microsoft Windows, and Developing & Running your first JSP Pageby Faisal Khan.
Overview
In this article I'll introduce what is JSP and why at all do we need to learn it. Then I'll move on to describe the installation of open source Servlet Container/JSP Engine, Tomcat. Once done, I'll explain the steps of running your first JSP page. Note that I am not going to describe the structure of a JSP page and what are the different features of JSP, I'll cover them in a separate article.
What is JSP?
JSP stands for 'Java Server Pages'. These are pages which are used to serve dynamic content to the user using logic and data (XML, Database etc) on the server side. JSP is a part of J2SE (Java 2 Standard Edition) and along with Java Servlets and Java
Beans is used to develop efficient, scalable and secure web applications in quick time.
Why bother with JSP when ASP is already here?
Nice question, first of all ASP is not the only solution out there which supports rapid web application development, there are others like PHP, Perl, ColdFusion etc. JSP is different from all of them because :
- JSP uses Java. Java is by far one of the most popular programming languages on the web. Its simpler syntax and 'write once run anywhere' capability makes it THE server side programming language of choice. So JSP pages and Java applications that you
create will run on almost all major operating systems e.g. Windows, UNIX, Mac etc. You don't need to create separate apps for separate platforms.
- JSP is part of J2EE. J2EE (Java 2 Enterprise Edition) is one of the most popular models used to develop Enterprise level applications. J2EE is supported by software giants like Sun Microsystems, BEA, Oracle, IBM etc. So once you learn to program JSP, you can extend
your skills to learn other Java technologies to become what is called, an Enterprise Software Developer.
- Networking is built into Java. Java's inherent support for networking makes it an ideal langauge for the internet.
I can continue to write more and more reasons as to why to use Java (JSP) but then it will make my article longer than I would like, so I suffice with the above features. Once you'll learn Java (JSP), you'll come to know what I mean when I say 'Java is the best
language for the internet'.
Continue reading to see the basic steps required in the installation of Tomcat 6.0 Servlet Container / JSP Engine. I'll be using Tomcat in the later articles and tutorials on 'Server Side Java' so you need to have it installed on your system.
Following is a list of topics we'll cover in this article :
You'll need to have JDK 1.6 (or simply 'JDK 6', as it is called on Sun's download page) installed on your system in order for Tomcat 6.0 to work properly. If you don't already have it, you can get it from java.sun.com.
Obtaining Tomcat 6.0
Tomcat 6.0 is an open source and free Servlet Container and JSP Engine. It is developed by Apache Software Foundation and is available for download
at
http://tomcat.apache.org, or more specifically at http://tomcat.apache.org/download-60.cgi. Choose the latest Tomcat 6.0 version. Currently Tomcat 6.0.14 is the latest version. Once you have downloaded Tomcat 6.0, proceed to the next step.
Installing Tomcat 6.0
Unzip the file to a suitable folder. In Windows, you can unzip it to C:\ which will create a directory like C:\apache-tomcat-6.0.14 containing Tomcat files.
Now you'll have to create two environment variables, CATALINA_HOME and
JAVA_HOME. Most probably you'll have JAVA_HOME already created
if you have installed Java Development Kit on your system. If not then you should create it. The values of these variables will be something like :
CATALINA_HOME : C:\apache-tomcat-6.0.14
JAVA_HOME : C:\Program Files\Java\jdk1.6.0_03
To create these environment variables in Windows 2000 or Windows XP, go to Start -> Settings -> Control Panel -> System -> Advanced -> Environment Variables -> System variables -> New. Enter the name and value for CATALINA_HOME and also for JAVA_HOME if not already there.
Under Windows 95/98, you can set these variables by editing C:\autoexec.bat
file. Just add the following lines and reboot your system :
SET CATALINA_HOME=C:\apache-tomcat-6.0.14
SET JAVA_HOME=C:\Program Files\Java\jdk1.6.0_03
Running Tomcat 6.0
Ok now, lets start Tomcat by running the C:\apache-tomcat-6.0.14\bin\startup.bat batch file. Tomcat server will start and print some status messasge. Now point your
browser to http://localhost:8080 and you should see the default Tomcat home page. To shutdown the server run C:\apache-tomcat-6.0.14\bin\shutdown.bat batch file.
Go to C:\apache-tomcat-6.0.14\webapps\ folder and create a new directory with the name of "star". You can give it any name you want but for this example we'll stick with "star".
Now create a new file and save it as 'index.jsp' in the "star" directory created above. Copy the following text into 'index.jsp' file and save it :
<html>
<head>
<style>p { font-family:tahoma; font-size:14pt; }</style>
</head>
<body>
<%
String name = "Faisal Khan";
%>
<p>Hello <%= name %>!</p>
</body>
</html> Overview
In this article I'll introduce what is JSP and why at all do we need to learn it. Then I'll move on to describe the installation of open source Servlet Container/JSP Engine, Tomcat. Once done, I'll explain the steps of running your first JSP page. Note that I am not going to describe the structure of a JSP page and what are the different features of JSP, I'll cover them in a separate article.
What is JSP?
JSP stands for 'Java Server Pages'. These are pages which are used to serve dynamic content to the user using logic and data (XML, Database etc) on the server side. JSP is a part of J2SE (Java 2 Standard Edition) and along with Java Servlets and Java
Beans is used to develop efficient, scalable and secure web applications in quick time.
Why bother with JSP when ASP is already here?
Nice question, first of all ASP is not the only solution out there which supports rapid web application development, there are others like PHP, Perl, ColdFusion etc. JSP is different from all of them because :
- JSP uses Java. Java is by far one of the most popular programming languages on the web. Its simpler syntax and 'write once run anywhere' capability makes it THE server side programming language of choice. So JSP pages and Java applications that you
create will run on almost all major operating systems e.g. Windows, UNIX, Mac etc. You don't need to create separate apps for separate platforms.
- JSP is part of J2EE. J2EE (Java 2 Enterprise Edition) is one of the most popular models used to develop Enterprise level applications. J2EE is supported by software giants like Sun Microsystems, BEA, Oracle, IBM etc. So once you learn to program JSP, you can extend
your skills to learn other Java technologies to become what is called, an Enterprise Software Developer.
- Networking is built into Java. Java's inherent support for networking makes it an ideal langauge for the internet.
I can continue to write more and more reasons as to why to use Java (JSP) but then it will make my article longer than I would like, so I suffice with the above features. Once you'll learn Java (JSP), you'll come to know what I mean when I say 'Java is the best
language for the internet'.
Continue reading to see the basic steps required in the installation of Tomcat 6.0 Servlet Container / JSP Engine. I'll be using Tomcat in the later articles and tutorials on 'Server Side Java' so you need to have it installed on your system.
Following is a list of topics we'll cover in this article :
You'll need to have JDK 1.6 (or simply 'JDK 6', as it is called on Sun's download page) installed on your system in order for Tomcat 6.0 to work properly. If you don't already have it, you can get it from java.sun.com.
Obtaining Tomcat 6.0
Tomcat 6.0 is an open source and free Servlet Container and JSP Engine. It is developed by Apache Software Foundation and is available for download
at
http://tomcat.apache.org, or more specifically at http://tomcat.apache.org/download-60.cgi. Choose the latest Tomcat 6.0 version. Currently Tomcat 6.0.14 is the latest version. Once you have downloaded Tomcat 6.0, proceed to the next step.
Installing Tomcat 6.0
Unzip the file to a suitable folder. In Windows, you can unzip it to C:\ which will create a directory like C:\apache-tomcat-6.0.14 containing Tomcat files.
Now you'll have to create two environment variables, CATALINA_HOME and
JAVA_HOME. Most probably you'll have JAVA_HOME already created
if you have installed Java Development Kit on your system. If not then you should create it. The values of these variables will be something like :
CATALINA_HOME : C:\apache-tomcat-6.0.14
JAVA_HOME : C:\Program Files\Java\jdk1.6.0_03
To create these environment variables in Windows 2000 or Windows XP, go to Start -> Settings -> Control Panel -> System -> Advanced -> Environment Variables -> System variables -> New. Enter the name and value for CATALINA_HOME and also for JAVA_HOME if not already there.
Under Windows 95/98, you can set these variables by editing C:\autoexec.bat
file. Just add the following lines and reboot your system :
SET CATALINA_HOME=C:\apache-tomcat-6.0.14
SET JAVA_HOME=C:\Program Files\Java\jdk1.6.0_03
Running Tomcat 6.0
Ok now, lets start Tomcat by running the C:\apache-tomcat-6.0.14\bin\startup.bat batch file. Tomcat server will start and print some status messasge. Now point your
browser to http://localhost:8080 and you should see the default Tomcat home page. To shutdown the server run C:\apache-tomcat-6.0.14\bin\shutdown.bat batch file.
Go to C:\apache-tomcat-6.0.14\webapps\ folder and create a new directory with the name of "star". You can give it any name you want but for this example we'll stick with "star".
Now create a new file and save it as 'index.jsp' in the "star" directory created above. Copy the following text into 'index.jsp' file and save it :
<html>
<head>
<style>p { font-family:tahoma; font-size:14pt; }</style>
</head>
<body>
<%
String name = "Faisal Khan";
%>
<p>Hello <%= name %>!</p>
</body>
</html>
|