You are on page 1of 22

School of Engineering Technology and Applied Science

Department of Information and Communication Engineering Technology

COURSE CODE: COMP 303

COURSE TITLE: Java EE Programming


Servlets

Professor : Dr. Aime M. Mbobi


1
Servlets

• Go to this link, read and apply basic examples of HTML


http://www.w3schools.com/html
Servlets

• Locations
Java Resources: src
R-click and New  Package
Never use default package

src/myServletPackage
Java code in myServletPackage

WebContent
Web files (HTML, JavaScript, CSS,
JSP, images, etc.)

WebContent/some-subdirectory
Web content in subdirectory
R-click on WebContent, New  Folder

WebContent/WEB-INF
web.xml (Optional with servlets 3.0.
Required in 2.5 & earlier.
Creating HTML files on Server and
Displaying content from Client Browser

4
Creating an HTML File

5
Servlets
Servlets

Select HTML
Servlets

Name it
index.html
Servlets

Select HTML5
Servlets

Insert the title of your text

Insert what you would


like to display
Running a Project

11
Servlets
Servlets
Servlets
Servlets
Servlets
Starting a Server and Testing URL

17
Servlets

• Start Server
R-click Server at bottom

Start (use “Restart” if already running)

• Test URL
http://localhost:8080/app/ in any Web browser
Creating HTML files on Server - Displaying content from Client Browser

19
Servlets

Lab 2_1

• Create a new project named Lab4_1

• Under WebContent folder:


Create a file Lecture1.html that displays the below text
Open your preferred browser and paste the URL in and observe the result
Your HTML tutorial is a good tool to help you formatting your output.
Display the result on your screen
Servlets

Lab 2_2

• Under the same folder


Create a file Lecture2.jsp that displays the below text

Open your preferred browser and paste the URL in and observe the result
Servlets

Lab 2_3

• Download css file (style) from eCentennial (Under Document)


Create a file index.html that displays the following page with the same format.
Lecture1.html link will launch the lecture1.html file and Lecture2.html link will
launch the lecture2.html file
Open your preferred browser and paste the URL in and observe the result
Display the same result on your cell phone
Use two different laptops to realize the client/server concept

You might also like