Chapter 7. Outline of Web  application and Eclipse.

ITSS Java Programming  NGUYEN Hong Quang, HUT

Outline of WWW

Client

URL address Link in a  Web page Request

Web server

Web  browser Internet

HTML file,  program file,  multimedia  file : image  file, sound  file, movie  file, etc.

Response Display  reading page

HTTP protocol

 Data is transmitted on Internet by HTTP

protocol

 HTTP response:

 Response message  Contents type  Requested file

 HTTP request:  HTTP method  Request URI   ‘form’ data

“form” data exemple

HTTP method : GET and  POST

 GET

 Add transmission information to URL.  There is a limitation in the length of the

transmission character string.

 Example: http://localhost:8080/examples/hello?

NAME=Billy

 POST

 There is not a limitation in the length of the

transmission character string.

 It is possible to transmit only by 

 tag.

Web application

Client

URL address Link in a  Web page Request Application server

Web  browser

Run  application Internet

Response Display  reading page

Features of Web application

 Application server

 It has the execution environment such as Web

containers,

 the connecting function to database: MySQL, SQL

Server, etc.

 transaction management function to couple two or more

processing, and more.

 Web container :

 an execution environment to execute the server

applications (CGI) : Servlet and JSP, ASP, PHP, etc.

 example is ‘Tomcat’, etc.

Directory structure of Web application  (Tomcat)

Web server  ROOT directory

 can be directly accessed  from the Web browser

HTML file, JSP file, image  files, etc.

 The contents are not  open to the client

WEB_INF

 configuration file

web.xml

 class file

classes

 class file

lib

Collaboration between Servlet, JSP and  JDBC

Application server

Request

Web  browser

Servlet DBMS JDBC

JSP pages

Response

 Servlet : Java program that runs on Server side

(Web container)

 JSP :  Embedding the Java program into the HTML

files

Display  reading page

Using directly JDK

 Edit program : Editor (NotePad)

 Execution program : Dos Prompt :

The role and composition of IDE

 IDE : integrated development environment  Characteristics :

 editor and compiler are integrated  All processes from editing to execution can be

done with one set of software

 Java IDE Exemples :

 Eclipse  Visual Studio (Microsoft)  Sun ONE Studio (Sun)

Characteristics of Eclipse

 Eclipse is an IDE (free, open source) for Java

application

 Extension of Functions through plug­in  Code assistance (Input assistance function)  Automatic build function  Refactoring, debugger, etc.

 Web site of Eclipse Project

http://www eclipse org

Eclipse

Install plug­ins

 Download plug­ ins necessary  Unzip and copy  it to plugins  directory of  Eclipse

 Restart Eclipse

Eclipse

Main screen of Eclipse

Text Editor

Class view

Package  Explorer  View

Console view : output screen, compile error and alert messages

Eclipse

Code assistance : Supplementation  with method name

Eclipse

Code assistance : Supplementation  with class name

CTRL + Space

Eclipse

Java programming with Eclipse

Start of Eclipse

Making of project

Making of class

Build and Execution

End of Eclipse

Eclipse

Start of Eclipse : step 1

Eclipse

Start of Eclipse : step 2

Eclipse

Start of Eclipse : step 3

Workbench

Eclipse

Making project 1

Eclipse

Making project 2

Eclipse

Making project 3

Eclipse

Making class 1

Eclipse

Making class 2

Eclipse

Making class 3

Eclipse

Run application in Eclipse

Eclipse

Default directory of Eclipse project

Eclipse

Change directory 1

Eclipse

Change directory 1

Eclipse

Execution of class that uses  command line argument 1

Eclipse

Execution of class that uses  command line argument 2

Eclipse

Execution of class that uses  command line argument 3

Eclipse

Setting of class passing 1 (JDBC driver)

Eclipse

Setting of class passing 2 (JDBC driver)

Eclipse

Setting of class passing 3 (JDBC driver)

Eclipse

Close project

Open project (1)

Open project (2)

Open project (3)

Open project (4)

End of Eclipse

Hands­on exercises 1

 Install

 JDK 6.0   Eclipse version 3.4.2  Apache Tomcat 6.0.18

 install server  install Tomcat plug­ins 3.2.1 in Eclipse

Hands­on exercises 2

 Verifier structure directory of Tomcat Web

server   InputName.htm

 Test program (create project, insert class,

build and execution) :   HelloWorld  HelloWorld with input parameter