LAB 1 PREPARED BY : DR. AJUNE WANIS ISMAIL FACULTY OF COMPUTING UNIVERSITI TEKNOLOGI MALAYSIA

Similar documents
This tutorial will teach you how to use Java Servlets to develop your web based applications in simple and easy steps.

Web based Applications, Tomcat and Servlets - Lab 3 -

The Basic Web Server CGI. CGI: Illustration. Web based Applications, Tomcat and Servlets - Lab 3 - CMPUT 391 Database Management Systems 4

UNIT-V. Web Servers: Tomcat Server Installation:

SERVLETS INTERVIEW QUESTIONS

Advanced Internet Technology Lab # 4 Servlets

INTRODUCTION TO SERVLETS AND WEB CONTAINERS. Actions in Accord with All the Laws of Nature

JAVA SERVLET. Server-side Programming INTRODUCTION

Servlet Fudamentals. Celsina Bignoli

JdbcResultSet.java. import java.sql.*;

Module 4: SERVLET and JSP

The Servlet Life Cycle

HttpServlet ( Class ) -- we will extend this class to handle GET / PUT HTTP requests

Servlet Basics. Agenda

Spring framework was initially written by Rod Johnson and was first released under the Apache 2.0 license in June 2003.

Java Servlets. Preparing your System

SSC - Web applications and development Introduction and Java Servlet (I)

Enterprise Java Technologies (Part 1 of 3) Component Architecture. Overview of Java EE. Java Servlets

Unit 4 - Servlet. Servlet. Advantage of Servlet

Database Applications Recitation 6. Project 3: CMUQFlix CMUQ s Movies Recommendation System

Java Enterprise Edition. Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1

AJP. CHAPTER 5: SERVLET -20 marks

Enterprise Java Unit 1- Chapter 4 Prof. Sujata Rizal Servlet API and Lifecycle

Servlets by Example. Joe Howse 7 June 2011

sessionx Desarrollo de Aplicaciones en Red A few more words about CGI CGI Servlet & JSP José Rafael Rojano Cáceres

Session 8. Introduction to Servlets. Semester Project

Chettinad College of Engineering and Technology CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE AND TECHNOLOGY

Servlets1. What are Servlets? Where are they? Their job. Servlet container. Only Http?

Java E-Commerce Martin Cooke,

Advanced Topics in Operating Systems. Manual for Lab Practices. Enterprise JavaBeans

Java servlets CSCI 470: Web Science Keith Vertanen Copyright 2013

Advanced Web Technology

Servlets and JSP (Java Server Pages)

********************************************************************

Supplement IV.E: Tutorial for Tomcat For Introduction to Java Programming By Y. Daniel Liang

Introduction to Servlets. After which you will doget it

Connecting the RISC Client to non-javascriptinterfaces

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2

Introduction to Java Servlets. SWE 432 Design and Implementation of Software for the Web

Servlets Basic Operations

Introduction. This course Software Architecture with Java will discuss the following topics:

Servlets. An extension of a web server runs inside a servlet container

INTERNET PROGRAMMING TEST-3 SCHEME OF EVALUATION 1.A 3 LIFE CYCLE METHODS - 3M 1.B HTML FORM CREATION - 2 M

Session 9. Introduction to Servlets. Lecture Objectives

Introduction. Literature: Steelman & Murach, Murach s Java Servlets and JSP. Mike Murach & Associates Inc, 2003

Questions and Answers

Introduction to Java. Lecture 1 COP 3252 Summer May 16, 2017

First Servlets. Chapter. Topics in This Chapter

4.1 The Life Cycle of a Servlet 4.2 The Java Servlet Development Kit 4.3 The Simple Servlet: Creating and compile servlet source code, start a web

Distributed Systems 1

1. Introduction. Java. Fall 2009 Instructor: Dr. Masoud Yaghini

Servlet. 1.1 Web. 1.2 Servlet. HTML CGI Common Gateway Interface Web CGI CGI. Java Applet JavaScript Web. Java CGI Servlet. Java. Apache Tomcat Jetty

Database Systems Lab. 11. JSP I 충남대학교컴퓨터공학과 데이타베이스시스템연구실

Introduction to JAVA Programming Language

Purpose. Why use Java? Installing the Software. Java

DevPartner Java Edition System Requirements Release

2. Follow the installation directions and install the server on ccc. 3. We will call the root of your installation as $TOMCAT_DIR

DevPartner Java Edition System Requirements Release 4.3

Introduction. This course Software Architecture with Java will discuss the following topics:

Chapter 10 Servlets and Java Server Pages

文字エンコーディングフィルタ 1. 更新履歴 2003/07/07 新規作成(第 0.1 版) 版 数 第 0.1 版 ページ番号 1

Enterprise Java Unit 1- Chapter 3 Prof. Sujata Rizal Introduction to Servlets

A Servlet-Based Search Engine. Introduction

1 OBJECT-ORIENTED PROGRAMMING 1

Developing a Mobile Web-based Application with Oracle9i Lite Web-to-Go

CS506 today quiz solved by eagle_eye and naeem latif.mcs. All are sloved 99% but b carefull before submitting ur own quiz tc Remember us in ur prayerz

Implementation Architecture

GAUTAM SINGH STUDY MATERIAL SOFTWARE QUALITY Unit 7. Concordion

Setting Up the Development Environment

Lab session Google Application Engine - GAE. Navid Nikaein

a. Jdbc:ids://localhost:12/conn?dsn=dbsysdsn 21. What is the Type IV Driver URL? a. 22.

AIML - QUICK GUIDE AIML - INTRODUCTION

Data Source Name (Page 150) Ref: - After creating database, you have to setup a system Data Source Name (DSN).

Adobe Flex Tutorial i

Module 3 Web Component

Université du Québec à Montréal

Unit 5 JSP (Java Server Pages)

Java Training For Six Weeks

UNIT -5. Java Server Page

Outline. Introduction to Java. What Is Java? History. Java 2 Platform. Java 2 Platform Standard Edition. Introduction Java 2 Platform

Servlets. How to use Apache FOP in a Servlet $Revision: $ Table of contents

Implementation Architecture

Servlet for Json or CSV (or XML) A servlet serving either Json or CSV (or XML) based on GET parameter - This version uses org.json

Stateless -Session Bean

Web Services. GC: Web Services Part 3: Rajeev Wankar

Eng. Mohammed S. Abdualal

JAVA SERVLETS INTRODUCTION SERVLETS SHRI GURU RAM RAI INSTITUTE OF TECHNOLOGY & SCIENCE, DEHRADUN

This tutorial will take you through simple and practical approaches while learning AOP framework provided by Spring.

Apache Tomcat Installation guide step by step on windows

Getting started with Winstone. Minimal servlet container

Eng. Mohammed Alokshiya

ServletConfig Interface

Accessing EJB in Web applications

CHAPTER 2: A FAST INTRODUCTION TO BASIC SERVLET PROGRAMMING

Oracle Containers for J2EE

This page discusses topic all around using FOP in a servlet environment. 2. Example Servlets in the FOP distribution

WA1958 Mobile Software Design Patterns and Architecture Android Edition. Classroom Setup Guide. Web Age Solutions Inc.

JDB - QUICK GUIDE JDB - INTRODUCTION

COURSE 9 DESIGN PATTERNS

AN OVERVIEW OF SERVLET AND JSP TECHNOLOGY

Transcription:

LAB 1 PREPARED BY : DR. AJUNE WANIS ISMAIL FACULTY OF COMPUTING UNIVERSITI TEKNOLOGI MALAYSIA

Setting up Java Development Kit This step involves downloading an implementation of the Java Software Development Kit (SDK) and setting up PATH environment variable appropriately. You can download SDK from Oracle's Java site: Java SE Downloads. Once you download your Java implementation, follow the given instructions to install and configure the setup. Finally set PATH and JAVA_HOME environment variables to refer to the directory that contains java and javac, typically java_install_dir/bin and java_install_dir respectively.

Setting up Java Development Kit If you are running Windows and installed the SDK in C:\jdk1.5.0_20, you would put the following line in your C:\autoexec.bat file. set PATH=C:\jdk1.5.0_20\bin;%PATH% set JAVA_HOME=C:\jdk1.5.0_20 Alternatively, if you use an Integrated Development Environment (IDE) like Borland JBuilder, Eclipse, IntelliJ IDEA, or Sun ONE Studio, compile and run a simple program to confirm that the IDE knows where you installed Java.

Setting up Web Server: Tomcat Apache Tomcat is an open source software implementation of the Java Servlet and JavaServer Pages technologies and can act as a standalone server for testing servlets and can be integrated with the Apache Web Server. Here are the steps to setup Tomcat on your machine: Download latest version of Tomcat from http://tomcat.apache.org/. Once you downloaded the installation, unpack the binary distribution into a convenient location. For example in C:\apachetomcat-5.5.29 on windows, or /usr/local/apache-tomcat-5.5.29 on Linux/Unix and create CATALINA_HOME environment variable pointing to these locations.

Setting up Web Server: Tomcat Tomcat can be started by executing the following commands on windows machine: %CATALINA_HOME%\bin\startup.bat or C:\apache-tomcat-5.5.29\bin\startup.bat After startup, the default web applications included with Tomcat will be available by visiting http://localhost:8080/.

http://localhost:8080/ should display following result:

Setting up CLASSPATH Since servlets are not part of the Java Platform, Standard Edition, you must identify the servlet classes to the compiler. If you are running Windows, you need to put the following lines in your C:\autoexec.bat file. set CATALINA=C:\apache-tomcat-5.5.29 set CLASSPATH=%CATALINA%\common\lib\servletapi.jar;%CLASSPATH% NOTE: Assuming that your development directory is C:\ServletDevel (Windows) or /usr/servletdevel (Unix) then you would need to add these directories as well in CLASSPATH in similar way as you have added above.

servlet life cycle A servlet life cycle can be defined as the entire process from its creation till the destruction. The following are the paths followed by a servlet The servlet is initialized by calling the init () method. The servlet calls service() method to process a client's request. The servlet is terminated by calling the destroy() method. Finally, servlet is garbage collected by the garbage collector of the JVM.

The init() method : The init method is designed to be called only once. It is called when the servlet is first created, and not called again for each user request. So, it is used for one-time initializations, just as with the init method of applets. The servlet is normally created when a user first invokes a URL corresponding to the servlet public void init() throws ServletException { // Initialization code... }

The service() method : The service() method is the main method to perform the actual task. The servlet container (i.e. web server) calls the service() method to handle requests coming from the client( browsers) and to write the formatted response back to the client. public void service(servletrequest request, ServletResponse response) throws ServletException, IOException { }

The service() method : The service() method checks the HTTP request type (GET, POST, PUT, DELETE, etc.) and calls doget, dopost, doput, dodelete, etc. methods as appropriate. The service () method is called by the container and service method invokes doget, dopost, doput, dodelete, etc. methods as appropriate. So you have nothing to do with service() method but you override either doget() or dopost() depending on what type of request you receive from the client.

doget() and dopost() method. A GET request results from a normal request for a URL or from an HTML form that has no METHOD specified and it should be handled by doget() method. A POST request results from an HTML form that specifically lists POST as the METHOD and it should be handled by dopost() method. public void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { // Servlet code } public void dopost(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { // Servlet code }

Architecture Diagram First the HTTP requests coming to the server are delegated to the servlet container. The servlet container loads the servlet before invoking the service() method. Then the servlet container handles multiple requests by spawning multiple threads, each thread executing the service() method of a single instance of the servlet.