Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
33 views

Lecture-5 Internet Programming – Server Side Programming

Uploaded by

bebohassan3200
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Lecture-5 Internet Programming – Server Side Programming

Uploaded by

bebohassan3200
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

CS 4126 : Internet Technology

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

 ColdFusion is one of the easiest programming


environments to use, and enables you to create powerful
server-side web applications very quickly, with much less
code than other technologies such as ASP, PHP, etc.

 ColdFusion consists of two main elements:


 A ColdFusion server (which runs on top of your web server),

 ColdFusion templates (or files), which you write using


ColdFusion Markup Language (CFML).
What Can ColdFusion Do?
 Query a database
 Allow users to upload files
 Create/read files on the server (for example, the files that your
users upload)
 Send emails (for example, newsletters to a mailing list)
 Schedule tasks to run automatically (for example, your email
newsletters)
 FTP files to/from another server
 Publish web services
Server side: High-level
languages
Java servlets and JSPs,
ASP and ASP.NET
Java Servlets
 Java analogue of a CGI script
 A servlet is a Java class that runs on a web server and handles
requests from clients, such as browsers or other applications.
 Servlet is an API that provides many interfaces and classes
including documentations.
 A servlet can process data, and generate responses, usually in
the form of HTML, XML, or other formats.
 A servlet is not a standalone program, but a component that is
managed by a servlet container.
 The servlet container is responsible for loading, initializing,
executing, and destroying servlets, as well as providing them
with services such as security, concurrency, and
communication.
Java Servlets
 A servlet can service multiple requests in its lifetime
 More efficient than creating separate processes
 Servlets can interact and share information with other
components
 They can also invoke other HTTP requests and
include their results in their response
 Servlets have access to session information
 Sessions encoded either as cookies or in URL
 API hides details from the servlet programmer
 Servlets are good for intermediate service-oriented
documents
 e.g., XML data from a web service
Servlet
Advantage of Servlet
 Better performance: because it creates a thread for
each request not process.

 Portability: because it uses java language.

 Robust: Servlets are managed by JVM so we don't need


to worry about memory leak, garbage collection etc.

 Secure: because it uses java language


Servlet vs. CGI
 Servlet responses faster than CGI because it uses the
multithreading concept to service each request.
 CGI performance is not that good as it creates a new
object for each request while servlet allots a new thread
for each request.
 Learning and implementing servlet is quite easier
compared to CGI.
 Memory consumption is low in servlet compared to CGI.
Java Server Pages (JSP)
 Java Server Pages (JSP) is a technology for developing
Webpages that supports dynamic content.
 This helps developers insert java code in HTML pages
by making use of special JSP tags, most of which start
with <% and end with %>.
 A Java Server Pages component is a type of Java
servlet that is designed to fulfill the role of a user
interface for a Java web application.
 Web developers write JSPs as text files that combine
HTML or XHTML code, XML elements, and embedded
JSP actions and commands.
Java Server Pages (JSP)
 Using JSP, you can collect input from users through
Webpage forms, present records from a database or
another source, and create Webpages dynamically.
 JSP tags can be used for a variety of purposes, such as
retrieving information from a database or registering user
preferences, passing control between pages, and
sharing information between requests, pages etc.
How JSP Works
Application Server Browser
HTTP request

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

Web Form Web Service

Protocols: HTTP, .NET Framework Tools:


HTML, XML, Visual Studio.NET,
SOAP, UDDI Notepad
Windows

Your Internal .NET Foundation Third-Party .NET Enterprise


Web Service Web Services Web Services Servers
Web Forms
 Built with ASP.NET
 Logical evolution of ASP
 Similar development model: edit the page and go

 Requires less code

 New programming model


 Event-driven/server-side controls
 Rich controls (e.g. data grid, validation)
 Controls generate browser-specific code
 Simplified handling of page state
ADO.NET
 ADO stands for Microsoft ActiveX Data Objects.
 ADO.NET is one of Microsoft’s Data Access Technologies,
which we can use to communicate with different data sources.
 It is a part of the .NET Framework, which establishes a
connection between the .NET Application and different data
sources.
 The Data Sources can be SQL Server, Oracle, MySQL, XML,
etc. ADO.NET consists of a set of predefined classes that can
be used to connect, retrieve, insert, update, and delete data (i.e.,
performing CRUD operation) from data sources.
 ADO.NET is designed to provide a bridge between your
application code and the underlying data sources.
What Types of Applications
Use ADO.NET?
 ASP.NET Web Form Applications
 Windows Applications
 ASP.NET MVC Application
 Console Applications
 ASP.NET Web API Applications
 ASP.NET Core Applications

You might also like