This document provides a summary of server-side programming concepts including servlets, session handling, database connectivity using JDBC, and Java Server Pages (JSP). It discusses the servlet life cycle, Apache Tomcat installation, GET and POST methods, cookies, JDBC drivers, and the JSP lifecycle. Key topics covered include how servlets receive and process requests, maintain session state, connect to databases, and how JSP pages are translated and executed on the server-side to generate dynamic web content.
Servlet is java class which extends the functionality of web server by dynamically generating web pages.
Servlet technology is used to create Dynamic web application. Servlet technology is robust and scalable. init() and service() methods are more important in life cycle of a servlet. doGet() and doPost() are methods used under service() method.
The presentation deals with ASP.NET page life cycle and gives you a brief introduction of the events that are fired during each phaze of page processing.
Chapter 02: Classes Objects and Methods Java by Tushar B KuteTushar B Kute
The lecture was condcuted by Tushar B Kute at YCMOU, Nashik through VLC orgnanized by MSBTE. The contents can be found in book "Core Java Programming - A Practical Approach' by Laxmi Publications.
What is the DOM?
The DOM is a W3C (World Wide Web Consortium) standard.
The DOM defines a standard for accessing documents:
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
The W3C DOM standard is separated into 3 different parts:
Core DOM - standard model for all document types
XML DOM - standard model for XML documents
HTML DOM - standard model for HTML documents
The HTML DOM (Document Object Model)
When a web page is loaded, the browser creates a Document Object Model of the page.
The HTML DOM model is constructed as a tree of Objects.
With the HTML DOM, JavaScript can access and change all the elements of an HTML document.
This ppt tells about struts in java. All the methods and brief knowledge of struts. For more info about struts and free projects on it please visit : http://s4al.com/category/study-java/
Servlet is java class which extends the functionality of web server by dynamically generating web pages.
Servlet technology is used to create Dynamic web application. Servlet technology is robust and scalable. init() and service() methods are more important in life cycle of a servlet. doGet() and doPost() are methods used under service() method.
The presentation deals with ASP.NET page life cycle and gives you a brief introduction of the events that are fired during each phaze of page processing.
Chapter 02: Classes Objects and Methods Java by Tushar B KuteTushar B Kute
The lecture was condcuted by Tushar B Kute at YCMOU, Nashik through VLC orgnanized by MSBTE. The contents can be found in book "Core Java Programming - A Practical Approach' by Laxmi Publications.
What is the DOM?
The DOM is a W3C (World Wide Web Consortium) standard.
The DOM defines a standard for accessing documents:
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
The W3C DOM standard is separated into 3 different parts:
Core DOM - standard model for all document types
XML DOM - standard model for XML documents
HTML DOM - standard model for HTML documents
The HTML DOM (Document Object Model)
When a web page is loaded, the browser creates a Document Object Model of the page.
The HTML DOM model is constructed as a tree of Objects.
With the HTML DOM, JavaScript can access and change all the elements of an HTML document.
This ppt tells about struts in java. All the methods and brief knowledge of struts. For more info about struts and free projects on it please visit : http://s4al.com/category/study-java/
Hierarchical Digital Twin of a Naval Power SystemKerry Sado
A hierarchical digital twin of a Naval DC power system has been developed and experimentally verified. Similar to other state-of-the-art digital twins, this technology creates a digital replica of the physical system executed in real-time or faster, which can modify hardware controls. However, its advantage stems from distributing computational efforts by utilizing a hierarchical structure composed of lower-level digital twin blocks and a higher-level system digital twin. Each digital twin block is associated with a physical subsystem of the hardware and communicates with a singular system digital twin, which creates a system-level response. By extracting information from each level of the hierarchy, power system controls of the hardware were reconfigured autonomously. This hierarchical digital twin development offers several advantages over other digital twins, particularly in the field of naval power systems. The hierarchical structure allows for greater computational efficiency and scalability while the ability to autonomously reconfigure hardware controls offers increased flexibility and responsiveness. The hierarchical decomposition and models utilized were well aligned with the physical twin, as indicated by the maximum deviations between the developed digital twin hierarchy and the hardware.
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Dr.Costas Sachpazis
Terzaghi's soil bearing capacity theory, developed by Karl Terzaghi, is a fundamental principle in geotechnical engineering used to determine the bearing capacity of shallow foundations. This theory provides a method to calculate the ultimate bearing capacity of soil, which is the maximum load per unit area that the soil can support without undergoing shear failure. The Calculation HTML Code included.
Final project report on grocery store management system..pdfKamal Acharya
In today’s fast-changing business environment, it’s extremely important to be able to respond to client needs in the most effective and timely manner. If your customers wish to see your business online and have instant access to your products or services.
Online Grocery Store is an e-commerce website, which retails various grocery products. This project allows viewing various products available enables registered users to purchase desired products instantly using Paytm, UPI payment processor (Instant Pay) and also can place order by using Cash on Delivery (Pay Later) option. This project provides an easy access to Administrators and Managers to view orders placed using Pay Later and Instant Pay options.
In order to develop an e-commerce website, a number of Technologies must be studied and understood. These include multi-tiered architecture, server and client-side scripting techniques, implementation technologies, programming language (such as PHP, HTML, CSS, JavaScript) and MySQL relational databases. This is a project with the objective to develop a basic website where a consumer is provided with a shopping cart website and also to know about the technologies used to develop such a website.
This document will discuss each of the underlying technologies to create and implement an e- commerce website.
Cosmetic shop management system project report.pdfKamal Acharya
Buying new cosmetic products is difficult. It can even be scary for those who have sensitive skin and are prone to skin trouble. The information needed to alleviate this problem is on the back of each product, but it's thought to interpret those ingredient lists unless you have a background in chemistry.
Instead of buying and hoping for the best, we can use data science to help us predict which products may be good fits for us. It includes various function programs to do the above mentioned tasks.
Data file handling has been effectively used in the program.
The automated cosmetic shop management system should deal with the automation of general workflow and administration process of the shop. The main processes of the system focus on customer's request where the system is able to search the most appropriate products and deliver it to the customers. It should help the employees to quickly identify the list of cosmetic product that have reached the minimum quantity and also keep a track of expired date for each cosmetic product. It should help the employees to find the rack number in which the product is placed.It is also Faster and more efficient way.
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
1. UNIT 3- SERVER SIDE PROGRAMMING
1
CS8651 - INTERNET
PROGRAMMING
2. • Servlets: Java Servlet Architecture - Servlet Life Cycle - Form
GET and POST actions
• Session Handling - Understanding Cookies - Installing and
Configuring Apache Tomcat Web Server -
• DATABASE CONNECTIVITY: JDBC perspectives, JDBC
program example
• JSP: Understanding Java Server Pages - JSP Standard Tag Library
(JSTL)-Creating HTML forms by embedding JSP code. 2
UNIT III: SYLLABUS
5. • Servlet is a technology which is used to create a web application.
• Servlet is an API that provides many interfaces and classes
including documentation.
• Servlet is an interface that must be implemented for creating any
Servlet.
• Servlet is a class that extends the capabilities of the servers and
responds to the incoming requests. It can respond to any requests.
• Servlet is a web component that is deployed on the server to create
a dynamic web page.
5
SERVLETS
7. • What is CGI?
– Common Gateway Interface (CGI) is a standard for writing programs that
can interact through a Web server with a client running on Web browser.
7
CGI vs. SERVLETS
8. 8
CGI vs. SERVLETS
Servlet
CGI(Common Gateway
Interface)
Servlets are portable and efficient. CGI is not portable
In Servlets, sharing of data is possible. In CGI, sharing of data is not possible.
Servlets can directly communicate with the
web server.
CGI cannot directly communicate with the
web server.
Servlets are less expensive than CGI. CGI are more expensive than Servlets.
Servlets can handle the cookies. CGI cannot handle the cookies.
9. • The components of Servlet Architecture are
– Client
– Web Server
– Web Container: Component in the webserver it interacts with Java servlets
which is responsible for managing the lifecycle of servlets and it also
performs the URL mapping task.
9
SERVLETS - ARCHITECTURE
10. • In General,
• But when a page requested by a client is different or may be build
at the time of request (Not in html format) or the server is not
having the file in the requested format(Dynamic Request), the
server need to build the page in the format requested.
• That process is done by the helper application called “Web
Container” which contains the Servlets.
• Servlet is basically a Java file which can take the request from the
client on the internet and it can process the request and provide the
response in the form of HTML.
10
SERVLETS - WORKING
11. • The client send the request to the server.
• The Web Server receives the request from the client.
• The webserver passes the request to correspondent Servlet in the
Web Container.
• The servlet process the request and generate the response in the
form of output.
• The servlet send the response back to the webserver and back to
client.
11
SERVLETS - WORKING
12. • The web container maintains the life cycle of a servlet instance.
• The life cycle of the servlet are as follows:
– Servlet Class is Loaded
– Servlet Instance is Created
– Init Method is Invoked
– Service Method is Invoked
– Destroy Method is Invoked
12
SERVLETS - LIFE CYCLE
Start
End
Ready
1. Load Servlet
Class
2. Create
Servlet
Instance
3. Call Init
Method
4. Call the
Service
Method
4. Call the
Destroy
Method
13. 13
SERVLETS - LIFE CYCLE
Create Initialize
Available for
Service
Servicing
Requests
Un available for
Services
Destroy
Unload
Initialization
Failed
Unavailable
- Exception
Throw
15. • Servlet Class is Loaded
– The class loader is responsible to load the Servlet Class.
– The Servlet class is loaded when the first request for the Servlet is received
by the Web Container.
• Servlet Instance is Created
– The Web Container creates the Instance of a servlet after loading the Servlet
Class.
– The Servlet instance is created only once in the servlet life cycle.
• init method is invoked
– The web container calls the init method only once after creating the servlet
instance.
– The init method is used to initialize the Servlet 15
SERVLETS - METHODS
16. – Init is available in Javax.Servlet.Servlet.Interface.
public void init(servletconfig config) throws ServletException
{
}
• Servlet Method is Invoked
– The web container calls the service method each time when the request for
servlet is received.
– If the servlet is initialized , it calls the servlet method.
Public void service (SerletRequest request, Servlet Response response) throws
ServletException, IOException
• Destroy Method is Invoked
– The web container calls the destroy method before removing the servlet
instance from the service. 16
SERVLETS - METHODS
17. • Tomcat is a Web Server that can run Java Web Applications like
Java Servlets, Java Server Pages (JSP), Java Expression Language
and Java Web socket.
• Tomcat is a powerful production-ready server that is used by many
small, medium and big companies.
• https://tomcat.apache.org/download-80.cgi - Link to download the
Apache Tomcat Web Server.
• Binary Distributions -> 32-bit/64-bit Windows Service
Installer (pgp, sha512)
17
APACHE TOMCAT INSTALLATION
19. • Before start installation, need to setup JAVA_HOME or
JRE_HOME and CATALINA_HOME so that you can do
some maintenance operations on the Tomcat server like
Starting and Stopping the Server.
19
APCHE TOMCAT INSTALLATION
20. • The parameters are the way in which a client or user can send
information to the Http Server.
• For example, in a login screen, we need to send to the server,
the user and the password so that it validates them.
20
PARAMETERS, GET AND POST METHODS
21. • The first thing we are going to do is to create in our site a page
"login.html" with the following content:
• Then, we create a Servlet which receives the request in /login ,
which is the indicated direction in the action attribute of the
tag <form> of login.html 21
PARAMETERS, GET AND POST METHODS
22. • Then Start the Webserver.
• Once the server starts, type http://localhost:8080/first-
servlet/login.html
• Then, we create a Servlet which receives the request in /login ,
which is the indicated direction in the action attribute of the
tag <form> of login.html 22
PARAMETERS, GET AND POST METHODS
23. • Session simply means a particular interval of time.
• Session Tracking is a way to maintain state (data) of an user.
• It is also known as session management in servlet.
• Http protocol is a stateless so we need to maintain state using
session tracking techniques.
• Each time user requests to the server, server treats the request
as the new request.
• So we need to maintain the state of an user to recognize to
particular user.
23
SESSION HANDLING
24. • Session Tracking is used to recognize the particular user and
their data.
• Session Tracking Techniques
– There are four techniques used in Session tracking:
• Cookies
• Hidden Form Field
• URL Rewriting
• HttpSession
24
SESSION HANDLING
25. • A cookie is a small piece of information that is persisted
between the multiple client requests.
• Cookies are text files stored on the client computer and they
are kept for various information tracking purpose.
• Java Servlets transparently supports HTTP cookies.
• Cookies can be used by a server to indicate session IDs,
shopping cart contents, login credentials, user preferences,
and more.
25
COOKIES IN SERVLET
26. • Server script sends a set of cookies to the browser. For
example name, age, or identification number etc.
• Browser stores this information on local machine for future
use.
• When next time browser sends any request to web server then
it sends those cookies information to the server and server uses
that information to identify the user. 26
COOKIES IN SERVLET
27. • There are 2 types of cookies in servlets.
• Non-persistent cookie
– It is valid for single session only.
– It is removed each time when user closes the browser
• Persistent cookie
– It is valid for multiple session .
– It is not removed each time when user closes the browser.
– It is removed only if user logout or sign-out.
27
TYPES OF COOKIE
28. Advantage of Cookies
• Simplest technique of maintaining the state.
• Cookies are maintained at client side.
Disadvantage of Cookies
• It will not work if cookie is disabled from the
browser.
• Only textual information can be set in Cookie object.
28
COOKIES
29. Cookie class
• javax.servlet.http.Cookie class provides the functionality of
using cookies.
How to create Cookie?
How to delete Cookie?
29
COOKIES
Cookie ck=new Cookie("user","sonoo jaiswal");//creating cookie object
response.addCookie(ck);//adding cookie in the response
Cookie ck=new Cookie("user","");//deleting value of cookie
ck.setMaxAge(0);//changing the maximum age to 0 seconds
response.addCookie(ck);//adding cookie in the response
30. • JDBC stands for Java Database Connectivity.
• JDBC is a Java API to connect and execute the query with
the database.
• JDBC API uses JDBC drivers to connect with the database.
• There are four types of JDBC drivers:
– JDBC-ODBC Bridge Driver,
– Native Driver,
– Network Protocol Driver, and
– Thin Driver
30
DATABASE CONNECTIVITY - JAVA JDBC
31. • JDBC API is a Java API that can access any kind of tabular
data, especially data stored in a Relational Database.
• JDBC works with Java on a variety of platforms, such as
Windows, Mac OS, and the various versions of UNIX.
Why Should We Use JDBC?
• Before JDBC, ODBC API was the database API to connect
and execute the query with the database.
• But, ODBC API uses ODBC driver which is written in C
language (i.e. platform dependent and unsecured).
31
DATABASE CONNECTIVITY - JAVA JDBC
38. • There are 5 steps to connect any java application with the
database using JDBC. These steps are as follows:
• Register the Driver class
• Create connection
• Create statement
• Execute queries
• Close connection
38
DATABASE CONNECTIVITY
39. • 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 fulfil the role of a user interface for a Java web
application.
39
UNDERSTANDING JSP
40. • Web developers write JSPs as text files that combine HTML
or XHTML code, XML elements, and embedded JSP actions
and commands.
• Using JSP, we 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, accessing JavaBeans components, passing
control between pages, and sharing information between
requests, pages etc. 40
UNDERSTANDING JSP
41. • 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:
– 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, including JDBC, JNDI, EJB, JAXP,
etc. 41
WHY USE JSP?
42. • The JSP pages follow these phases:
– Translation of JSP Page
– Compilation of JSP Page
– Classloading (the classloader loads class file)
– Instantiation (Object of the Generated Servlet is created).
– Initialization ( the container invokes jspInit() method).
– Request processing ( the container invokes _jspService()
method).
– Destroy ( the container invokes jspDestroy() method).
42
THE LIFECYCLE OF A JSP PAGE
44. • JSP page is translated into Servlet by the help of JSP
translator.
• The JSP translator is a part of the web server which is
responsible for translating the JSP page into Servlet.
• After that, Servlet page is compiled by the compiler and gets
converted into the class file.
• Moreover, all the processes that happen in Servlet are
performed on JSP later like initialization, committing response
to the browser and destroy.
44
THE LIFECYCLE OF A JSP PAGE
46. • As with a normal page, your browser sends an HTTP request
to the web server.
• The web server recognizes that the HTTP request is for a JSP
page and forwards it to a JSP engine.
• This is done by using the URL
(http://localhost:8888/myapplication/hello.jsp) or JSP page
which ends with .jsp instead of .html.
• The JSP engine loads the JSP page from disk and converts it
into a servlet content.
46
JSP PROCESSING
47. • This conversion is very simple in which all template text is
converted to println( ) statements and all JSP elements are
converted to Java code.
• This code implements the corresponding dynamic behavior of
the page.
• The JSP engine compiles the servlet into an executable class
and forwards the original request to a servlet engine.
• A part of the web server called the servlet engine loads the
Servlet class and executes it.
47
JSP PROCESSING
48. • During execution, the servlet produces an output in HTML
format.
• The output is further passed on to the web server by the servlet
engine inside an HTTP response.
• The web server forwards the HTTP response to your browser
in terms of static HTML content.
• Finally, the web browser handles the dynamically generated
HTML page inside the HTTP response exactly as if it were a
static page
48
JSP PROCESSING
50. • The Java Server Pages Standard Tag Library (JSTL) is a
collection of useful JSP tags which encapsulates the core
functionality common to many JSP applications.
• JSTL has support for common, structural tasks such as
iteration and conditionals, tags for manipulating XML
documents, and SQL tags, Etc.,
• It also provides a framework for integrating the existing
custom tags with the JSTL tags.
50
JSTL
51. • Fast Development: JSTL provides many tags that simplify the
JSP.
• Code Reusability: We can use the JSTL tags on various pages.
• No need to use scriptlet tag: It avoids the use of scriptlet tag.
51
ADVANTAGE OF JSTL