Please enable JavaScript.
Coggle requires JavaScript to display documents.
CHAPTER 1: OVERVIEW OF JAVA WEB DEVELOPMENT - Coggle Diagram
CHAPTER 1: OVERVIEW OF JAVA WEB DEVELOPMENT
What are web applications?
A web site where the HTML pages are
generated dynamically
A site builds HTML pages on the fly based on
user’s action
What are the Java Web Application?
Java web application consists of Java Server Pages and servlets
To run Java web application, web server MUST HAVE servlet/JSP
engine or servlet/JSP container
For servlet/JSP engine to work properly -> must be able to access
Java Development Kit (JDK)
Example of Web Server that having servlet/JSP engine are Apache
Tomcat, Glassfish, Sun Java Web Server, Jetty, etc
What are JSP and Servlet?
Read user’s action, normally from HTML form
Perform the works such as communicate to
the database, web service and etc.
Java code that runs on the web server
Returns HTML page that is generated
dynamically
Java Server Page (JSP)
JSP page – contains HTML tags, JSP elements to allow
server inserting dynamic content in the page.
JSP can change its contents based on input provided by
users.
Java server pages – technology for developing web
pages that include dynamic contents.
Allows integration with databases.
JSP-have a number of standard elements used to access JavaBeans components, passing control between pages, sharing information request, pages and users
Servlet
Servlet – Java class that run on the web server
Servlet does the processing for dynamic web
pages for web applications
Servlet receive both request and response from
web server.
Can be thought as Java Applets that run on the
servers instead of Web browser.
Servlet role- do processing for the application and forward the request and response objects to a JSP
Comparing JSP and Servlets
JSP
Contains static HTML
JSP to generate
HTML
HTML file with .jsp
extension
Has built-in JSP
objects
Servlets
Generate all HTML
More step to access
web objects
Java class file
Best practice
Integrate them (JSP & Servlets) both together
Servlets does the business logic
JSP handles the presentation view
Follow the Model-View-Controller (MVC)
Design Patterns
Spring
JSF
Struts
The architecture of Java Web Application
3-tier Architecture
Business rules layer- control the flow of application using servletm JavaBeans, EJB
Data access layer - as a medium to communicate with database using JDBC, etc
Presentation Layer- for GUI using HTML/HTML5, JavaScript , CSS , Ajax, JSP
N-tier Architecture
server layer
expanded functionality
user authentication
and sessions
perhaps multithreading
database
connectivity
3rd tier is a database layer
data persists beyond
request and response
client layer (web browser)
forms interface to
interact with data
2-tier Architecture
Server (simple web server)
web-server processing http
Using servlet, simple CGI
http response
earliest and low-end web-sites
Client (browser)
mainly for presentation of
information
serving mainly static (D)HTML
pages
http request
Differences between The Client-Server Architectures
2-Tier
Issues
more complex
"Thick" client
More costly
User
2-100
Benefits
faster execution
more scalable
Good security
Multi-Tier
Issues
very costly
very complex
Benefits
exceptional security
Fastest execution
"Thin" client
very scalable
Users
50-2000(+)
1-Tier
Benefits
inexpensive
very simple
no server needed
Issues
poor security
multi user issues
User
usually for 1 (or a few)
HTTP Transactions
Hypertext Transfer Protocol (HTTP) is a platform-independent, designed to enable communications between clients and servers
HTTP works as a request-response protocol
between a client and server
Uniform Resource Identifiers (URIs) identify resources on the
Internet
• Next in the URL is the server’s fully qualified hostname
URIs that start with http:// are called
URLs
A hostname is translated into an IP (Internet Protocol) address
The remainder of the URL after the hostname specifies the
resource’s location (/books) and name on the web server.
When given a web page URL, a web browser uses HTTP to
request and display the web page found at that address
Two common HTTP methods:
– GET
– POST
Differences between GET Method and Post Method
GET Method
Limits the query string to a specific
number of characters.
Good for debugging
.
Form data is added to end of URL as name/value pairs • theUrl?field1=value1&field2=value2…
Suitable for non-sensitive data
is used to request or retrieves data from a
server. Common uses: to retrieve an
HTML document or an image, or search
results based on a user-submitted search
term
Post Method
No limitation on data length
Can send binary data
Form data is passed in the body of HTTP
request message
Suitable for sensitive data
Is used to send data to a server to create/update a resource. Common uses: to send information to a server, such as authentication information or data from a form that gather user input
HTTP Status Codes
400-Bad request, server could not understand (Client error)
401-unauthorized, authorization challenge (Client error)
304-Not Modified: the client or proxy copy is still up-to-date
(Redirection)
403-forbidden, server refuses to fulfill request; e.g. check
protections (Client error)
301-Moved permanently, new location is specified in Location:
header (Redirection)
404-Not found, document does not exist (Client error)
201-Created, result is newly created (Successful)
500-Internal server error, generic error code for the server
200 -OK, request succeeded (Successful)
501-Not implemented, request could not be serviced because
server does not support it (Server error)
101 - 1 Switching Protocols, switching either the version or the
actual protocol (informative)
Client Scripting vs Server side Scripting
Client Scripting
Client-side scripts - can be viewed by the client by using the browser’s sourceviewing capability
Sensitive information, such as passwords
or other personally identifiable data, should not be stored or validated on the
client
have limitations, such as browser
dependency
JavaScript, VBScript
Run on web browser
used to validate user input, to interact with the browser, to enhance web pages, and to add client/server communication between a browser and a web server
Server-side Scripting
Code cannot be viewed by web browser
Can perform the business logic for
sensitive information
Depends on the web server; IIS only for
ASP.Net
Run on web server
JSP, ASPX, PHP
Used to perform business logic.
Accessing Web Server
Local web servers can be accessed through your
computer’s name or through the name localhost— translates to the IP address
127.0.0.1
Request documents from web servers - users must
know the hostnames on which the web server software resides
What are the type of Web Application?
Student/Employee tracking
Restaurant/Hotel/Flight reservations
e-Commerce
Social media
Key Building Blocks
JSP and servlets are key components of the
Java Enterprise Edition (Java EE)
• Popular Model-View-Controller (MVC) Design
Pattern are built on top of JSP and servlets
Development Environment
Local Area Network Development
Components required for client – IDE, JDK, JAR’s classes
that are not available in JDK, browser.
Hardware – Desktop PC/Notebook and Server.
Components required for server– JDK, Apache Tomcat &
MySQL.
For web application accessed by a number of users
Develop application done by a groups over intranet.
Internet Development
Components required for client – IDE, JDK, JAR’s classes
that are not available in JDK, browser
Hardware – Desktop PC/Notebook and Servers
Components required for server– JDK, Sun Java Web
Server & MySQL
For web application accessed by via Internet.
• Develop application done by a groups over internet. E.g.
offshore development
Stand-alone Development
Components required – JDK, Apache Tomcat & MySQL
For stand-alone web application
Develop on your own computer
Setting Up the Environment Development
Required Software
Java Application Server such as Glassfish, JBoss,
WebLogic, Jetty and etc. Tomcat Server
Java Integrated Development Environment (IDE)
such as Eclipse, NetBeans NetBeans IDE
Java Development Kit (JDK)