Archive for the ‘Web Development’ Category
Web Development – Getting Started
Web Development – Getting Started
This section explains how to setup an environment to develop web applications in Java and then provides examples of JSP’s and Servlets that connect to a DBMS. The software components used will be as follows:
J2SE 1.4.2
MySQL JDBC Driver
MySQL 6.0
Tomcat 5.5.23
I will add some code for creating JSPs and Servlets that connect to an RDDMS very soon.
Setting up the Environment
1) Download J2SE SDK from the Sun Microsystems website, which is http://java.sun.com/j2se/1.4.2/download.html at the time of writing. Then launch the setup file and install the product.
2) Create a new Environmental Variable called JAVA_HOME, which points to C:\Program Files\Java\jdk1.4.2, assuming you chose the installation path C:\Program Files\Java when installing.
3) Add ‘.’ (Without quotes) to the classpath variable. This will allow you to compile Java programs in any directory.
4) Download the MySQL database from MySQL, which is http://dev.mysql.com/downloads/mysql/6.0.html#win32 at the time of writing.
5) Download the MySQL JDBC driver from the MySQL website, which is http://dev.mysql.com/downloads/connector/j/5.0.html at the time of writing.
6) Copy mysql-connector-java-5.0.6-bin.jar to C:\Program Files\Java\jdk1.4.2\jre\lib and C:\apache-tomcat-5.5.23\common\lib.
7) Download Tomcat from Apache, which is http://tomcat.apache.org/download-60.cgi at the time of writing. Select the zip file under Core Binary Distributions.
8) Copy Servlet-api.jar from C:\apache-tomcat-5.5.23\common\lib to C:\Program Files\Java\jdk1.4.2\lib. This will allow you to compile Java Servlets.
9) Create a new Environmental Variable called CATALINA_HOME, which points to C:\Tomcat\JAKARTA-5.5.23.
10) Start the Tomcat server; run Startup.bat (contained in the Bin directory).
11) Go to http://localhost:8080/ to test the Tomcat installation. The Tomcat welcome page should appear.
12) Stop the Tomcat server, run Shutdown.bat (contained in the Bin directory).
Note 1: The Tomcat server receives requests on port 8080 by default, however it is possible to change this. Microsoft Internet Information Server receives requests on port 80, so I would suggest avoiding the use of port 80 for Tomcat if you have IIS running unless you don’t mind stopping the IIS service every time Tomcat is used. To change the Tomcat port:
13) Open C:\apache-tomcat-5.5.23\conf\server.xml using Notepad or Wordpad.
14) Change the following:
Http10Connector port=”8080″
secure=”false”
maxThreads=”100″
maxSpareThreads=”50″
minSpareThreads=”10″ />
To the following:
<Http10Connector port=”80″
secure=”false”
maxThreads=”100″
maxSpareThreads=”50″
minSpareThreads=”10″ />
Tomcat can now be accessed as http://localhost/.


