Posted on Leave a comment

Apache Tomcat 7.0 (on Windows) install guide

Apache Tomcat is a widely used open-source implementation of the Java Servlet and JavaServer Pages (JSP) technologies.

Visit the Apache Tomcat homepage. Then, click the “Download” link for Tomcat 7.0 on the left.

Download the “32-bit/64-bit Windows Service Installer”.

Run the installer.

Remember the HTTP connector port. Also, pick an administrator login and password.

Specify the patch to the Java Runtime (JRE) if it is not already detected.

Take note of the location where your Tomcat server is being installed.

A tray icon will appear for the service monitor!

Right click on the monitor tray icon. Observe if the Tomcat service is already stated.

Click “Configure…” to open the service properties window. Make sure the “Startup type” is set to “Manual”. Also, stop the service if necessary.

That’s it! You’re done.

Posted on Leave a comment

Java Development Kit (JDK) install guide

This tutorial will step you through getting the Java Development Kit (JDK) installed on your computer, which you will need to compile Java programs. This is different from the Java Runtime Environment (JRE) which is used to run Java programs. The JRE will also be installed as part of this process.

Check if it’s installed

First you should check if you already have it installed on the computer you are working on.

Open the Windows “Control Panel” and click “Programs and Features”.

Look for both of these items. If they are present, you already have JDK and JRE.

Check processor type

You need to know your processor’s architecture in order to continue.

Go back to the “Control Panel” and click “System”.

Under the “System type” field, see if you’re using a 64-bit or 32-bit processor.

Downloading the installer

* Link to download page *

Make sure to select the correct download based on your processor’s architecture.

Running the installer

Take note of the location of the JDK installation. You will need it later.

Take note of the location of the JRE installation. You will need it later.

That’s it! You’re done.

Posted on Leave a comment

Eclipse + JavaServer Pages (JSP) beginner’s tutorial

Eclipse is a widely used open-source integrated development environment (IDE).

Visit the Eclipse download page. Find the download for “Eclipse IDE for Java EE Developers”. Select the appropriate version for your computer (it must match the JDK/JRE you have installed)!

Extract the archive’s contents. There is no need to run any setup program.

Navigate to the newly extracted ‘eclipse’ folder and run ‘eclipse.exe’.

The workspace directory is where Eclipse will store all your projects.

Let’s make a new project! Click “File”, then “New”, then “Other…” (or press Ctrl+N).

If you don’t see “Dynamic Web Project” the most common cause is because you did not download the “Java EE” edition of Eclipse.

Since this is the first JSP project, Eclipse doesn’t know about the Tomcat installation. After configuring a “New Runtime” it should be available in the dropdown menu for future use.

Don’t check “Create a new local server”.

Remember where you installed Tomcat? Enter that path or browse to it.

Tomcat should now be an option :^)

A blank canvas awaits you…

Let’s make our first JSP page. Right click on the ‘WebContent’ folder.

We want JSP – not HTML – since we are going to have some dynamically generated content. Although there is nothing wrong with using pure HTML files for static content.

Recall that files named ‘index.*’ will be the default “home page” served up by the webserver.

There are some predefined templates available. You don’t have to use them, but they are convenient.

Enter the example code highlighted in yellow. What do you think it will do?

Click the green run button on the toolbar so we can find out.

Once you confirm your selection here, Eclipse shouldn’t ask you again for this project.

Create a new Tomcat server on your localhost for development of this project.

Your project will be built and a Tomcat server will be started (see the “Servers” tab.)

Your default page will be loaded inside Eclipse’s internal web browser!

If you see “4” (the result of “2+2”) then you have successfully generated a dynamic page!

Browse to your local Tomcat instance in a “real” web browser.

View the source code of the page.

Check it out… you only see the result of the code executed between the start and end of the JSP tags. The actual source code is not revealed to the client.

Shut down your Tomcat server from within Eclipse by clicking the red stop button.

Further Reading

There are a number of JSP tutorials (of varying quality) freely available online.

Here’s a decent one I stumbled across:

I definitely suggest you read both tutorials and a JSP reference to understand the features, power, and flexibility of the language. Remember: it doesn’t matter if you are outputting HTML, XML, JSON, whatever… it’s all delivered over HTTP.

That’s it! You’re done