Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Go From Zero to JSP 2.0 in No Time at All : Page 2

Java Server Pages 2.0 promises to make it easier for beginners and non-programmers to code highly functional, dynamic Web sites. Learn to use JSP 2.0 to connect to a database and display dynamic results on your very own web page using new features such as the expression language.


advertisement
Install the Java Runtime Environment and Tomcat 5.0.5
The first thing you need to do is download the Java 2 SDK and install it. As I write this the latest version is 1.4.2. Download the Windows installation from the SDK column under "Download J2SE 1.4.2." Run the installer with all the defaults.

You'll also need a JSP 2.0 compliant application server. Download Tomcat 5.0.5 and install the directory at the root of your drive. Call it C:\Tomcat 5.0\.

Start the server (Start -> All Programs -> Apache Tomcat 5 -> Start Tomcat). Then open a Web browser and browse to http://localhost:8080. You should see there, displayed in all its glory, the Tomcat 5.0 welcome page. If you want, you can take a few minutes to check out the example pages http://localhost:8080/jsp-examples/ and http://localhost:8080/servlets-examples/.

There are many folders under the C:\Tomcat 5.0\ directory, but right now we are only interested in the C:\Tomcat 5.0\webapps\ROOT folder. This will be our playground for the rest of this article.

Configure and Install Needed Libraries
Under the ROOT folder there are a few files and a folder called WEB-INF. WEB-INF is a part of all Java 2 Web applications and is not exposed to the Web user through a URL such as //localhost/:8080/WEB-INF. The WEB-INF folder holds the application configuration, the Java libraries required for your application, and any Java classes that you create.

Create a directory named lib in your WEB-INF folder (i.e. C:\Tomcat 5.0\webapps\ROOT\WEB-INF\lib). Copy the files standard.jar and jstl.jar from C:\Tomcat 5.0\webapps\jsp-examples\WEB-INF\lib and put them into your new lib directory. These are library components (.jar files) that will have to be available to your application to complete this tutorial.

Download the appropriate Java database drivers (also .jar files) and place them into the lib directory you just created. The example code uses a SQL Server database, so you will need the database drivers (.jar files) provided by Microsoft (click on "SQL Server 2000 Driver for JDBC"—Read our review of the driver). The executable for the SQL Server 200 Driver for JDBC installs .jar files and Help documentation onto your computer. You will need to copy the three .jar files from its install directory into your WEB-INF/lib directory.

Now you need to modify the application's configuration file, named web.xml. Open the web.xml file (C:\Tomcat 5.0\webapps\ROOT\WEB-INF\web.xml) and locate, toward the top, the opening XML tag <web-app>. Replace this opening tag with:

<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd" version="2.4">

Save and close the web.xml file, right click the Tomcat icon in the system tray, and select Shutdown. Then restart it again from your Start menu. You can make some changes without restarting, but restarting is generally a good way to confirm that your changes are loaded and in effect.

Now you have a platform onto which you can unleash your brilliant Java Powered mind!



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date