Server Side Development
1 of 23
Server Side Development
Tiered Architecture
• The two-tiered client-server model has been superceded by
the multi-tiered architecture prevelant in the enterprise
applications
• Allows each layer to communicate just with layers above and below it
• Benefits of having a tiered application
• Encapsulates rules and functionality together providing for easier
maintenance & development
• Enhances flexibility and reusability of logic and software components
• Allows developers to focus on the area of their speciality e.g.
database, servers, web page, etc.
Application/Browser Web Server Database/ FileSystem
(User Interface) (Application Logic) (Persistent Storage)
of 23 2
Server Side Development
Web Server
• A web server is a program running on the server that
listens for incoming requests and services those requests
as they come in.
• Once the web server receives a request, depending on the
type of request the web server might look for a web page,
or it might execute a program on the server.
• It will always return some kind of results to the web
browser, even if its simply an error message saying that it
couldn’t process the request.
• By default the role of a web server is to serve static pages
using the http protocol
• Web servers can be made dynamic by adding additional
processing capability to the server
of 23 3
Server Side Development
Server Extensions
• Several different tools are available for extending
the server capabilities
• Java enterprise architecture
• VB .Net architecture
• Active Server Pages (ASP)
• CGI-Perl scripting
• These tools process incoming requests from the
user and generate custom html pages
of 23 4
Server Side Development
Tomcat
• Tomcat is a stand alone web server and a servlet container
• It is open source and free for usage
• It is written in Java
• You do not have to be a Java programmer to use it
• It’s web server is not as fully featured as others like Apache
• Installing Tomcat
• Make sure that jdk18 (or higher) is installed on your machine
• Download the latest windows version of Tomcat
• Run the installer by double clicking on the download
• The installer checks if JRE and JDK are available for Tomcat
• Accept the license agreement
• Installation directory: c:\Program Files\Apache Tomcat
• On installation you get a message Completed
of 23 5
HTTP
6 of 23
HTTP
Application Layer Protocol
• User applications implement this protocol
• Other protocols implemented by the OS.
• Different applications use different protocols
• Web Servers/Browsers use HTTP
• File Transfer Utilities use FTP
• Electronic Mail applications use SMTP
• Naming Servers use DNS
• Interacts with transport layer to send messages
of 23 7
HTTP
Application Layer Protocol, cont’d.
Socket Socket
TCP/UDP TCP/UDP
with with Buffers
Process Process
Buffers and and
Variables Variables
Internet
Controlled by Controlled by Controlled by Controlled by
Application Operating Operating Application
Developer System System Developer
HOST HOST
• Two parameter required for identifying the receiving process
• Host machine identifier - IP Address (localhost or ip-address)
• Host machine process identifier - Port (80 or 8080 for web
server)
of 23 8
HTTP
HyperText Transfer Protocol
• Lightweight protocol for the web involving a single
request & response for communication
• Provides 8 methods
• Get: Used to request data from server
(By convention get will not change data on server)
• Post: Used to post data to the server
• Head: returns just the HTTP headers for a resource.
• Put: allows you to "put" (upload) a resource (file) on to a
webserver so that it be found under a specified URI.
• Delete: allows you to delete a resource (file).
• Link and Unlink: Connect and Disconnect two resources.
• Options: To determine the type of requests server will handle
• Trace: Debugging
of 23 9
HTTP
GET and POST
• GET and POST allow information to be sent back to the web server
from a browser
• e.g. when you click on the “submit” button of a form the data in the
form is send back to the server, as "name=value" pairs.
• Choosing GET as the "method" will append all of the data to the URL
and it will show up in the URL bar of your browser.
• The amount of information you can send back using a GET is restricted
as URLs can only be 1024 characters.
• A POST sends the information through a socket back to the
webserver and it won't show up in the URL bar.
• This allows a lot more information to be sent to the server
• The data sent back is not restricted to textual data and it is possible to
send files and binary data such as serialized Java objects.
of 23 10
HTTP
HTTP Headers
• Contains information about client and the request
• Four categories of header information
• General Information: Date, caching information, warnings etc.
• Entity Information: Body of the request or response e.g. MIME type,
length etc.
• Request Information: Information about client e.g. cookies, types of
acceptable responses etc.
• Response Information: Information about server e.g. cookies,
authentication information etc.
• General & Entity information used for both client & server
• Request information included by client
• Response information included by server
of 23 11
HTTP
Protocol
• HTTP is a stateless protocol
• Request/Response occurs across a single network connection
• At the end of the exchange the connection is closed
• This is required to make the server more scalable
• Web Sites maintain persistent authentication so user does not
have to authenticate repeatedly
• While using HTTP persistent authentication is maintained using
a token exchange mechanism
• HTTP 1.1 has a special feature (keep-alive) which allows clients
to use same connection over multiple requests
• Not many servers support this
• Requests have to be in quick succession
of 23 12
HTTP
Tracking State
• Three types of tracking methods are used:
• Cookies: Line of text with ID on the users cookie file
• URL Session Tracking: An id is appended to all the links in
the website web pages.
• Hidden Form Elements: An ID is hidden in form elements
which are not visible to user
• Custom html page allows the state to be tracked
of 23 13
HTTP
HTTP Status Codes
• When a server responds to a request it provides a status code
• Web Container automatically handles setting of status codes
• Five categories of status codes
• Informational
• Success
• Redirection
• Client error
• Server error
• Common Status Codes
• 200 – Request was processed normally
• 401 – Unauthorized access
• 403 – Forbidden
• 404 – Requested resource not found on server
• 405 – Method Not allowed
• 500 – Internal server error
of 23 14
J2EE Architecture
J2EE – Container Architecture
Client Tier 3rd & Nth Tiers
Applet Container
Applet
Application Container
Middle Tier
Database
Application J2EE Server
J J J J Web Container EJB Container
internet internet
D A A M
X A S Servlets JSPs EJBs Enterprise
B
C P S Information
System
JavaMail/JAF
JavaMail/JAF
Connections
Connections
JAXP
JAXP
JDBC
JDBC
JAAS
JAAS
JMS
JTA
JMS
JTA
J2EE Server
J2EE Server
J2ME App
Non-Java Sever
Other
Application or
Server
of 23 15