Reading:  

Introduction to Servlet technology


Setting up environment for Servlets

Like other Java program servlet can be compiled using javac compiler, it can be deployed in configured environment to run.

Setting up Java Development Kit

The step involve downloading an implementation of Java Software Development Kit (SDK) and setting up of PATH environment variable appropriately.

Java SDK can be downloaded from Oracle's Java site: Java SE Downloads.

Click on JDK download.

java installers

After the setup files are download double click on the downloaded exe and install JDK

JDK Installer

After installation is complete, Configure PATH and JAVA_HOME in environment variables section. We will also need to create a new variable called JAVA_HOME. An example paths that would want to put in are shown below but these paths will change depending on where you end up installing JDK in the first place anyway.

PATH = C:\Program Files\Java\jdk1.8.0_40\bin;
JAVA_HOME= C:\Program Files (x86)\Java\jdk1.8.0_40

Here is how we created JAVA_HOME variable under windows OS and edited Path variable

setting JAVA_HOME variable under windows

Editing path variable for windows

Once set, open command prompt and to verify that JAVA_HOME is set correctly, run this command below

Verify JAVA_HOME

 

Setting up Web Server: Tomcat

Apache Tomcat is open source software implementation for Java Servlet and Java Server Pages technologies which act as standalone server for testing servlets and integrated with Apache Web Server. The Steps for setup of Tomcat:

  • Latest version of Tomcat can be Download from http://tomcat.apache.org/.
  • After download unpack binary distribution into a convenient location. Example C:\apache-tomcat-8.0.21 on windows

    tomcat server binary distribution

  • Configure CATALINA_HOME in environment variable section by adding New User Variable for CATALINA_HOME.

    CATALINA_HOME setup

  • Verify the CATALINA _HOME path by typing below command in command prompt.

    Verify CATALINA_HOME

  • Start Apache Web Server by running startup.bat from Command Prompt.

    Start tomcat server

After tomcat starts up, default web applications will be running in http://localhost:8080/.

Tomcat startup

 

Now that we have set ourselves up to pay with servlets, let's jump into understanding life cycle of a servlet in next part of this quick start tutorial on Servlets.

 

Description

This guide introduces Servlet technology and we will cover below topics

  1. What is a Servlet?
  2. Initial Setup
  3. Life Cycle
  4. Various Examples
  5. Client Request
  6. Server Response
  7. Http Status Codes
  8. Writing Filters
  9. Exception Handling
  10. Cookies Handling
  11. Session Tracking
  12. Database Access
  13. Packaging
  14. Internationalization

This is to the point introduction to the topic to get you started

 



Prerequisites

Working knowledge of Core Java is essential

Audience

Beginner to Java Servlet technology or students looking to brush up their skills quickly

Learning Objectives

Learn Java Servlets

Author: Subject Coach
Added on: 2nd May 2015

You must be logged in as Student to ask a Question.

None just yet!