Networking Web & Technologies
Networking Web & Technologies
Advantages of XHTML
XHTML allows you to define and use your own tags.
It follows the standards of XML, making it portable.
XHTML is easier to maintain as the rules are clear.
It is easy to upgrade the documents.
XHTML is sustainable.
XHTML has closing tags, making it advantageous for beginners.
Step 1 : Client i.e. web browser sends the request to the web server.
Step 2 : Web server receives the request and sends it to the servlet container.
Servlet container is also called web container or servlet engine. It is
responsible for handling the life of a servlet.
Step 3 : Servlet container understands the request’s URL and calls the
particular servlet. Actually, it creates a thread for execution of that servlet. If
there are multiple requests for the same servlet, then for each request, one
thread will be created.
Step 4 : Servlet processes the request object and prepares response object
after interacting with the database or performing any other operations and
sends the response object back to the web server.
Step 5 : Then web server sends the response back to the client.
Advantages Of Servlets :
As servlets support all protocols like FTP, SMTP, HTTP etc. they can be
used to develop any kind of web applications like E-commerce, Content
management systems, chat based or file based web applications etc.
As servlets are fully compatible with Java, you can make use of wide range
of available Java APIs inside the servlets.
As servlets are written in Java, you can extend them according to your
requirements.
As servlets are compiled into bytecodes, they are faster than any other
server-side scripting languages.
Disadvantages Of Servlets :
Designing a servlet can be pretty difficult.
Exceptions need to be handled while designing a servlet.
Developers may need additional skills to program a servlet.
The web container maintains the life cycle of a servlet instance.
life cycle of the servlet as follows:
Servlet class is loaded.
Servlet instance is created.
init method is invoked.
service method is invoked.
destroy method is invoked.
Java Servlets Life Cycle
Types of Cookie
There are 2 types of cookies in servlets.
Non-persistent cookie
Persistent cookie
1. Non-persistent cookie
It is valid for single session only.
It is removed each time when user closes the browser.
2. Persistent cookie
3. It is valid for multiple session .
4. It is not removed each time when user closes the browser.
5. It is removed only if user logout or signout.
Advantage of Cookies
6. Simplest technique of maintaining the state.
7. Cookies are maintained at client side.
Disadvantage of Cookies
8. It will not work if cookie is disabled from the browser.
9. Only textual information can be set in Cookie object.
The server-side is made up of three parts: the database, the server, the APIs, and
the backend web software written in the server-side scripting language. When a
browser requests a page with server-side scripting, the web server evaluates the
script before delivering the page to the browser. In this case, script processing may
entail collecting information from a database, performing simple computations, or
selecting the relevant material to be shown on the client end. The output is
provided to the web browser when the script is processed. The web server hides the
scripts from the end user until the content is delivered, making the data and source
code safer.
Python
PHP
Ruby
It is a free and open-source programming language that was developed and firstly
introduced in the early 1990s. It is a dynamic language that is simple to read and
write and an OOPs language that is interpreted as it runs. It has evolved
continuously since its development and is one of the most utilized web
development languages.
1. It is connected with data access, error handling, and data processing speed.
2. It is processed and interacts with the server.
3. Using a highly integrated programming language makes it more secure than
client-side scripting.
HTML
CSS
CSS is an abbreviation for Cascading Style Sheets. It provides a technique for
creating graphic elements that help a web application's appearance look more
appealing. A style tag in a web page defines all the specifics regarding the web
page's presentation, including its border styles, image styles, colour, font styles,
borders, format, font size, margins, padding, etc.
JavaScript
1. It is intended to execute code on which a web browser runs, and the results
of the inputs are delivered to an accessible user.
2. Client-side scripting enables greater involvement with clients via the browser and is used to
validate programs and functionality based on the request.
3. The client does not include any contact with the server in client-side scripting; the only
interaction is receiving the requested data
Benefits
Concurrency enables the efficient utilization of system resources and can improve
the overall performance and responsiveness of the application.
Multithreading
SIP Servlet
A SIP Servlet application can specify the required level of concurrency control.
A Java servlet container or web server is multithreaded and multiple requests to the
same servlet may be executed at the same time. Therefore, we need to take
concurrency into consideration while writing servlet.
As we discussed earlier that one and only one instance of Servlet gets created and
for every new request , Servlet Container spawn a new thread to execute doGet() or
doPost() methof of a servlet.
In this chapter we will discuss about concurrency in servlets and this is very
important concept so your attention is required.
Threads Overview
A thread is a lightweight process which has its own call stack and accesses shared
data of other threads in the same process (shares heap memory). Every thread has
its own memory cache.
This means that more than one sequential flow of control runs through the same
memory block.
Before actually Thread1 increments the counter another Thread1 increments the
counter which changed the value of counter to 11
There are certain points which we should consider while writing servlets.
We recommend to synchronize the block where your code modifies the instance
variables instead of synchronizing complete method for the sake of performance.
b. Single Thread Model –Implements SingleThreadModel interface to make
our thread single threaded which means only one thread will execute
service() or doXXX() method at a time. A single-threaded servlet is slower
under load because new requests must wait for a free instance in order to
proceed.
Servlets are simple Java programs that are helpful to create dynamic content
on the server side.
Servlets of two types:
1. Generic Servlets: These are Protocol independent
2. HTTP Servlets: These are protocol dependent
Here doGet() and doPost() are the two common methods used for taking
requests and sending responses back to the server.
When we call the doGet() or doPost() methods first the Service() method is
called and then only the doGet() or doPost methods are called accordingly.
How Server side programming works. Explain in detail?
Server-side scripts are programs that run on a web server to generate dynamic
web pages, creating a unique experience for each user. These scripts form the
basic framework for back-end web development.
Every website splits into two parts: the front end and the back end. The front
end, or client-side component, contains all the visuals and buttons that help
you interact with the website.
The back end controls how each visual and button responds.
This scenario better explains how back-end web development works. When a
user visits a website, the front-end code sends a request to the back end for the
data it needs.
The back end then fetches the requested data from the database and sends it to
the front end. The front-end code then renders the data in the user’s browser.
The back end has several key components, each playing an important role in
how the site functions. They include the server, database, and web apps.
The server is responsible for storing and delivering the website’s files.
Each time a user loads a webpage, their device sends a request to the
server for the files needed to display the page. The server then sends
the requested files to the user’s device, which assembles them into a
webpage and displays it to the user.
Databases store all the data that a website needs, such as user
information, search history articles, and comments. The database might
be relational, like Oracle and Microsoft SQL Server, or cloud -based,
like Microsoft Azure and Amazon Web Services (AWS).
Back-end web applications are codes written in back-end programming
language and are responsible for the functionality of a website. They
run on a web server to handle user authentication, database
management, and server-side rendering tasks. Understanding different
languages and software is a big part of web development.
Websites communicate with web servers via a uniform resource locator (URL),
which helps the site locate specific codes from the server. Every time a user
clicks a button on a website, it translates the command into a web address
before communicating with the server to retrieve relevant information.
The URL, or web address, has several parts, each narrowing the search on the
server.
Protocol. This scheme tells how the computer will communicate with
the server over the internet. Web servers use the Hypertext Transfer
Protocol (HTTP), which allows computers worldwide to share
information over the internet. Many web servers add a Secure Socket
Layer (SSL) protocol to better secure the interaction by encrypting
each session.
Domain. This part of the web address helps identify whic h server holds
the information the user requests. Usually, each domain registers under
the global Domain Name System (DNS), which helps the user’s
computer locate the host and location of the server.
Pathname. This URL section contains the complete details about where
the file or webpage resides on the server.
The server may use various retrieval methods depending on the file type. It
uses the HTTP “GET” command to retrieve static resources like JavaScript,
CSS, images, .zip, .jar, and PDF files. Static resources are files that don’t
change, even after several requests. The server returns an error message if it
doesn’t find the file.
It retrieves relevant data from the database, combines the Hypertext Markup
Language (HTML) templates, translates the message into an HTML page, and
transmits the message to the user.
Server-side script basics
Besides creating a personalized user experience, the server relies on the back -
end code to store login details, manage the source code, run relevant analyses
on user behavior, and control who has access to information in the database.
JavaScript
Here are some examples of companies that use JavaScript for their website’s
back end.
Netflix
Facebook
Uber
PayPal
Java
Take a look at some examples of brands that use Java to power their back -end
system.
Amazon
eBay
Spotify
Pinterest
Python
In addition, Python has features like data types and dynamic typing, making it
an excellent scripting language. Today, Python has become one of the most
popular programming languages in the world. Check out these major
organizations that use it.
Google
Reddit
Dropbox
The National Aeronautics and Space Administration (NASA)
PHP
PHP has many features that make it excellent for back-end web development.
It supports object-oriented programming, has a built-in development server,
and can be integrated with many databases. PHP also has a large community of
developers who contribute to the language, create helpful resources, and
develop extensions that add extra functionality.
Slack
MailChimp
Tumblr
WordPress
Ruby
Ruby has gained popularity for its straightforward syntax and robust
functionality. It combines features of PHP and SQL-based databases, creating
a dynamic language focused on simplicity and productivity. Ruby is also
highly expressive and useful for writing concise and readable codes.
Those reasons and more make Ruby an excellent language for back-end
programming. It helps you write programs that are easy to understand and
maintain.
Several very large organizations that serve millions of people use Ruby-
powered websites.
Twitter
Hulu
Airbnb
GitHub
Ruby on Rails
Express.js
Django
Flask
Laravel
Spring Boot
Spring Boot is one of the most popular Java frameworks for developing
microservices. It’s a lightweight framework with various features and
functionalities that make it easier to develop, deploy, and run microservices.
Some of Spring Boot’s key features include embedded servers, which make it
easy to deploy Spring Boot applications. Spring Boot can also automatically
configure itself based on the dependencies it detects in the project.