Lecture-5 Internet Programming – Server Side Programming
Lecture-5 Internet Programming – Server Side Programming
Lecture-5
Internet Programming – Server
Side Programming
Server-Side Code
What is server-side code?
Software that runs on the server, not the client
Receives input from
URL parameters
HTML form data
Cookies
HTTP headers
Can access server-side databases, e-mail servers,
files, mainframes, etc.
Server-Side Code
What is server-side code?
Server side code can be developed in a variety of
computer languages, including PHP, Python, Ruby,
C#, and NodeJS.
The server side code has complete access to the
operating system, and the developer can use
whichever programming language (and version) they
choose.
Server-Side Code
Server side programming languages are used by
companies like Amazon to generate product search
results, offer targeted product suggestions, and so on.
Banks utilize server side programming languages to
store account information and restrict access to just
authorized users.
Server side programming is used by other services such
as Facebook, Twitter, Instagram, and Wikipedia to
highlight, distribute, and regulate access to interesting
material.
Server-Side Code
Server side uses
It processes the user input
Displays the requested pages
Structure of web applications
Interaction with servers/storages
Interaction with databases
Querying the database
Encoding of data into HTML
Operations over databases like delete, update
Server-Side Code
Why server-side code?
Accessibility
You can reach the Internet from any browser, any device, any time,
anywhere
Manageability
Does not require distribution of application code
Easy to change code
Security
Source code is not exposed
Once user is authenticated, can only allow certain actions
Scalability
Web-based 3-tier architecture can scale out
Advantages of
Server-Side Code
Run scripts on the server, reducing the burden on the user's
machine.
Database web applications may be created using server side
scripting.
Even if users access the source code, server side scripting is used
to hide scripts from them; only client side scripts are shown.
Used to quickly create dynamic websites with content that can be
changed at any moment by the site administrator.
Because server side scripts are not browser-dependent, we don't
have to worry about browser versions.
Complex activities may be completed in a few stages thanks to
server side scripting.
It's simple to understand and utilize.
Disadvantages of
Server-Side Code
Debugging web server scripts is tricky.
Web server scripting is a hacking vulnerability.
Hosting a web server can be taxing on a
computer since it necessitates a big amount of
RAM, lowering the system's speed.
Server side: Scripting
and low-level languages
CGI, Perl, java, PHP, Python,
ColdFusion
Common Gateway Interface (CGI)
CGI is a standard interface enables the web server to
call an external program and pass HTTP request
information to the external program to process the
request.
For each request, it starts a new process.
Any programming language can be used
Compile into executable binary
Run scripts (e.g., perl) with executable interpreter
Document returned via standard output
Should return content-type header
Can refer to other document with Location
Common Gateway Interface
(CGI)
CGI Limitations
Not appropriate for busy servers
Each program instance is a separate process
If number of clients increases, it takes more time for
sending response.
For each request, it starts a process and Web server
is limited to start processes.
Security risks
Only web-master has install privileges
Bad code can cause serious trouble
PERL
Practical Extraction and Report Language [1987]
Perl is a general purpose, high level interpreted and dynamic
programming language
Originally developed for text manipulation and now used for a
wide range of tasks including system administration, web
development, network programming, GUI development, and
more.
Perl supports both the procedural and Object-Oriented
programming.
Perl takes the best features from other languages, such as C,
BASIC, among others.
Perls database integration interface DBI supports third-party
databases including Oracle, Sybase, Postgres, MySQL and
others.
PERL
Perl works with HTML, XML, and other mark-up
languages.
Perl supports Unicode.
Perl interfaces with external C/C++ libraries through XS
Perl used to be the most popular web programming
language due to its text manipulation capabilities and
rapid development cycle.
Perl can handle encrypted Web data, including e-
commerce transactions.
The Perl interpreter can be embedded into other
systems.
Java
Java is a popular object-oriented programming language
created in 1995.
It is owned by Oracle, and more than 3 billion devices
run Java.
It is used for:
Mobile applications (specially Android apps)
Desktop applications
Web applications
Web servers and application servers
Games
Database connection
AI, and cloud applications
Java Features
Platform-Independence: Java is highly portable and
can run on any platform with a JVM. This makes
developing and deploying applications easier without
worrying about compatibility issues.
Object-Oriented Programming: Java is a highly flexible
and modular language that supports object-oriented
programming. This allows developers to write modular,
reusable, and maintainable code, making scaling and
maintaining applications easier.
Automatic Memory Management: Java has automatic
memory management, making it easier to write code
without worrying about memory leaks or garbage
collection.
Java Features
Multi-threading: Java supports multi-threading, allowing
for the execution of multiple threads concurrently. This
feature helps develop highly scalable and efficient
applications.
Rich API Library: Java has a vast library of APIs that
can be used to build complex applications quickly. This
makes it easier for developers to build applications with
a wide range of features and functionalities, saving time
and effort.
PHP
Personal Home Page tools
but it now stands for the PHP: Hypertext
Preprocessor.
Open-source language for server-side scripting
Adopted in popular large-scale web-applications
Built-in facilities for popular protocols and services
Shifts towards OOP
PHP code is usually processed on a web server by
a PHP interpreter implemented as a module, or
a Common Gateway Interface (CGI) executable.
What Can PHP Do?
PHP can generate dynamic page content
PHP can create, open, read, write, delete, and close
files on the server
PHP can collect form data
PHP can send and receive cookies
PHP can add, delete, modify data in your database
PHP can be used to control user-access
PHP can encrypt data
PHP can output images or PDF files, can also
output any text, such as XHTML and XML.
Why PHP?
PHP runs on various platforms (Windows, Linux,
Unix, Mac OS X, etc.)
PHP is compatible with almost all servers used
today (Apache, IIS, etc.)
PHP supports a wide range of databases
PHP is free. Download it from the official PHP
resource: www.php.net
PHP is easy to learn and runs efficiently on the
server side
Python
A popular multi-paradigm language [’90]
Considers itself a “dynamic programming language” rather
than a scripting language
Used to build some large scale applications
Inherent object oriented programming
Variety of built-in data types
Extensible
It is used for:
web development (server-side),
software development,
mathematics,
system scripting.
What can Python do?
Python can be used on a server to create web
applications.
Python can be used alongside software to create
workflows.
Python can connect to database systems. It can also
read and modify files.
Python can be used to handle big data and perform
complex mathematics.
Python can be used for rapid prototyping, or for
production-ready software development.
Why Python?
Python works on different platforms (Windows, Mac,
Linux, Raspberry Pi, etc).
Python has a simple syntax similar to the English
language.
Python has syntax that allows developers to write
programs with fewer lines than some other programming
languages.
Python runs on an interpreter system, meaning that code
can be executed as soon as it is written. This means that
prototyping can be very quick.
Python can be treated in a procedural way, an object-
oriented way or a functional way.
ColdFusion
Macromedia’s server-side scripting language
HTML
HTTP response
Client
JSP is processed by
JSP Servlet
application server;
HTML is processed by
browser.
Server
Why Use JSP?
Java Server Pages often serve the same purpose as
programs implemented using the Common Gateway
Interface (CGI). But JSP offers several advantages in
comparison with the CGI:
Performance is significantly better because JSP allows
embedding Dynamic Elements in HTML Pages itself instead of
having separate CGI files.
JSP are always compiled before they are processed by the
server unlike CGI/Perl which requires the server to load an
interpreter and the target script each time the page is requested.
Java Server Pages are built on top of the Java Servlets API, so
like Servlets, JSP also has access to all the powerful Enterprise
Java APIs.
Apache Struts
A modern Java framework for building web
applications using a Model-View-
Controller (MVC) architecture
Model - Database interfaces such as JDBC or
EJB
View – Presentation interfaces such as JSP or
XSLT
Struts provides the controller
Active Server Pages (ASP)
Microsoft’s server-side technology
Technology to easily create server-side
applications
ASP pages are written in a scripting language,
usually VBScript or Jscript
An ASP page contains a sequence of static
HTML interspersed with server-side code
ASP script commonly accesses and updates
data in a database
Active Server Pages (ASP)
An Active Server Page (ASP) consists of HTML
and script.
HTML is sent to the client “as-is”
Script is executed on a server to dynamically generate
more HTML to send to the client.
Since it is generated dynamically, ASP can tailor the
HTML to the context in which it executes, e.g., based
on time, data from client, current server state, etc.
ASP.NET
.NET is a developer platform made up of tools,
programming languages, and libraries for building many
different types of applications.
ASP.NET is a New generation of .NET
ASP.NET is an open source web framework, created by
Microsoft, for building modern web apps and services
with .NET.
ASP.NET is cross platform and runs on Windows, Linux,
and macOS.
Supports visual editing similar to VB programming
ASP.NET
ASP.NET extends the .NET platform with tools and
libraries specifically for building web apps.
These are some things that ASP.NET adds to the .NET
platform:
Base framework for processing web requests in C#
Libraries for common web patterns, such as Model View
Controller (MVC)
Authentication system that includes libraries, a database, and
template pages for handling logins, including multi-factor
authentication.
Editor extensions to provide syntax highlighting, code completion,
and other functionality specifically for developing web pages
ASP.NET Platform
Clients Applications