Professional Documents
Culture Documents
}
}
1.BufferedReader
-----------------
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
EX:
---
import java.io.*;
class Test
{
public static void main(String[] args)throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter Text Data :");
String data=br.readLine();
System.out.print("Enter the same text data again :");
int val=br.read();
System.out.println("First Entered :"+data);
System.out.println("Second Entered :"+val+"["+(char)val+"]");
}
}
Note: If we want to take primitive data as dynamic input through BufferedReader
then we have to use wrapper classes explicitly.
a)Read primitive data in the form of String by using readLine() method
b)Convert data from String type to the respective primtive data type.
EX:
---
import java.io.*;
class Test
{
public static void main(String[] args)throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("First Value :");
String data1=br.readLine();
System.out.print("Second Value :");
String data2=br.readLine();
int val1=Integer.parseInt(data1);
int val2=Integer.parseInt(data2);
System.out.println("Addition :"+(val1+val2));
}
}
Scanner:
---------
-->It was provided by JDK5.0 version
-->It was provided in java.util package
-->It can be used to take primitive data as dynamic input directly with out
using wrapper classes.
Steps:
------
a)Create Scanner class Object
------------------------------
Scanner s=new Scanner(System.in);
EX:
---
import java.util.*;
class Test
{
public static void main(String[] args)throws Exception
{
Scanner s=new Scanner(System.in);
System.out.print("Enter Text Data :");
String data1=s.nextLine();
System.out.print("Enter the same text again :");
String data2=s.next();
System.out.println("First Eneterd :"+data1);
System.out.println("Second Eneterd :"+data2);
}
}
Console:
---------
--> It was introduced in JAVA6 version.
--> It was provided in java.io package.
Drawbacks with BufferedReader and Scanner:
1)For each and every single dynamic input we have to consume two instructions.
a)System.out.println(); to display request message.
b)The actual instuction to read dynamic input.
br.readLine() or s.next() or s.nextXXX()
Steps:
------
a)Create Console class object:
------------------------------
public static Console console()
EX: Console c=System.console();
EX:
---
import java.io.*;
class Test
{
public static void main(String[] args)throws Exception
{
Console c=System.console();
String uname=c.readLine("User Name :");
char[] pwd=c.readPassword("Password :");
String upwd=new String(pwd);
if(uname.equals("durga") && upwd.equals("durga"))
{
System.out.println("Login Success");
}
else
{
System.out.println("Login Failure");
}
}
}
Adv Java:
---------
1.JDBC
2.Servlets
3.JSPs
4.JSTL
5.EL
Databases:
-----------
Oracle
MySQL
Servers:
--------
Tomcat
Weblogic
JBOSS and Wildfly
Glassfish
IDEs
----
Editplus
Eclipse
MyEclipse
Netbeans
1.JDBC
-------
--> JDBC is a set by set by process to interact with database from Java
applications inorder to perform database operations from Java appl.
--> JDBC is a tech, it will proviode very good environment to connect with database
from java applications inorder to perform database operations from java
applications.
--> JDBC is an API[Collection of classes and interfaces], it will provide
environment to interact with database from java applications inorder to perform
database operations from java applications.
--> JDBC is an abstraction provided by SUN Micrystsems and implemented by all
database Vendors inorder to connect with database from java applications to perform
database operations from java appl.
Five Types
Type-1 Driver
Type-2 Driver
Type-3 Driver
Type-4 Driver
Type-5 Driver
Type-1 Driver
-------------
--> It also called as Bridge Driver or Jdbc-Odbc Driver.
--> It was provided by SUN Microsystems as reference implementation for Driver
interface iorder to provide enviironment for all the database vendors to
implement Driver interface.
--> SUN Microsystems has provided Type-1 drover in the form of
sun.jdbc.odbc.JdbcOdbcDriver in JAVA software along with java predefined
library.
--> This driver was provided by SUN Microsystems with the interdependncy on the
Microsoft product "ODBC Driver"[Open Database Connectivity].
--> ODBC is provided by Microsoft and implementd by using some native
implementations and it will provide very good environment to connect with any
type of Database from JDBC-ODBC Driver.
--> If we want to use Type-1 driver in JDBC applications then we must install
ODBC Driver [ODBC Native Library] in our System.
--> ODBC Driver is available bydefault in Microsoft products, but, it is not
available in Non Microsoft products bydefault, so that, Type-1 driver is
dependent on Microsoft propducts,Therefore, Type-1 driver is less portable
driver.
--> Type-1 driver is not suitable for Web Applications and Distributed appl.
--> Type-1 driver is suitable for Standalone Appl.
--> Type-1 driver is a reference impl, it is not for complex JDBC appl, it is
for simple JDBC appl requiurements.
--> Type-1 driver is slower driver, because, it must require two times
conversion inorder to interact with database from java appl.
1.From Java to ODBC by JDBC-ODBC Driver
2.From ODBC to DB repersentations by ODBC Driver
--> It will reduce JDBC application performance.
2.Type-2 Driver
----------------
--> It is also called as "Part java, part Native Driver" or simply "Native Driver".
--> Type-2 driver was prepared by using some java implementations and by using
Database Vendor provided native Library.
--> If we want to use Type-2 Driver in JDBC Applications then we have to install
the respective DB vendor provided native library in our
Machine.
--> When compared with Type-1 driver, Type-2 driver is more portable driver.
--> When compared with Type-1 driver, Type-2 driver is faster driver, Type-2 Driver
should not required two times conversions, it is sufficient to have one time
conversion to interact with database from java appl.
-->When compared with Type-1 driver, It will improve JDBC applications performance.
-->Type-2 Driver is not Economical Driver, it is costful.
-->Type-2 Driver is suggestible for Standalone applications only, not for web
applications and Distributed Applications.
Type-3 Driver:
---------------
--> Type-3 Driver is also called as "Middleware Database Access Server Driver" or
"Network Driver".
--> Type-1 and Type-2 Drivers are suggestible for only Standalone appl, but,Type-3
Driver is suggestible for Web applications and Distributed appl.
--> Type-1 driver is dependent on MS provided ODBC Driver, Type-2 Driver is
dependent on Database Vendor provided Native Library, but, Type-3 Driver is
dependent on Application Server which we have used for our applications.
--> Type-3 Driver is more portable driver when compared with Type-1 and Type-2
Drivers.
--> Type-3 Driver is faster Driver when compared with Type-1 and Type-2 Drivers,
because, Type-3 Driver is not required to perform two times conevrsions and it is
not required to load DB vendor provided native library, it is sufficient to start
application Server.
-->Type-3 driver will increase performance of the JDBC applications when compared
with Type-1 and Type-2 Drivers.
-->Type-3 Driver is able to provide very good environment to connect with multiple
databases from multiple clients[java appl] at a time.
-->It is not applicable for Standalone appl, because, it must require Server
environment.
Type-4 Driver
--------------
--> Type-4 Driver is also called as "Pure Java Driver" or "Thin Driver".
--> It was implemented completely on the basis of java implementations.
--> Type-4 Driver is more portable driver when compared with Type-1, Type-2 and
Type-3 Driver.
--> Type-4 Driver is suggestible for both Standalone applications and web
applications and Distributed Applications.
--> It is possible to use Type-4 driver with or with out application server.
--> Type-4 driver is frequently used driver in applications.
--> Type-4 driver is light weight driver and faster driver when compared with
Type-1,Type-2 and Type-3 Drivers.
--> Type-4 driver is most economical driver.
package java.sql;
public interface Driver// SUn
{
-----
}
package sun.jdbc.odbc;
public class JdbcOdbcDriver implements Driver// Sun Microsystems
{
-------
static
{
-----
DriverManager.registerDriver(--);
}
}
package java.sql;
public class DriverManager
{
----
public static void registerDriver(Driver d)
{
---logic to register Driver----
}
}
package com.durgasoft.jdbc;
public class JdbcApp
{
public static void main(String[] args)throws Exception
{
Class c=Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
-----
}
}
In case of Type-1 driver , If we use JDBC3.0 version, JAVA6 and above versions then
"Load and Register Driver" step is optional.
In case of Type-4 Driver provided by Oracle , if we use JDBC4.0 version, JAVA6 and
above versions and Oracle11g/ Oracle11xe version "Load and Register Driver " step
is optional.
java.sql package
Driver [I]
DriverManager [C]
Connection [I]
Statement [I]
PreparedStatement [I]
CallableStatement [I]
ResultSet [I]
ResultSetMetaData [I]
DatabaseMetaData [I]
----
----
Driver URL:
-----------
Type-1 Driver:
---------------
Driver_Class: sun.jdbc.odbc.JdbcOdbcDriver
Driver_URL: jdbc:odbc:nag
EX:
---
Connection con=DriverManager.getConnection("jdbc:odbc:nag", "system", "durga");
Q)In Jdbc, Connection is an interface, but, how getConnection() method will create
Connection object?
------------------------------------------------------------------------
Ans:
----
package java.sql;
public interface Connection// SUN
{
----services in the form of abstract methods----
}
package com.oracle.jdbc;
public class OracleConnectionImpl implements Connection// Oracle
{
---implementation for services-----
}
package java.sql;
public class DriverManager// SUN
{
------
public static Connection getConnection(String url, String db_User_Name,
String db_Pwd)throws SQLException
{
---Logic to identify DB_Vendor Provided JDBC impl----
----Establish connection between java appl and DB by calling
Driver.connect()-----
Connection con=new OracleConnectionImpl();
return con;
}
-------
}
class JdbcApp
{
public static void main(String[] args)
{
---Load n register driver----
Connection con=DriverManager.getConnection(---,---,--);
}
}
package java.sql;
public interface Statement// SUN
{
----
}
package com.oracle.jdbc;
public class OracleStatementImpl implements Statement// Oracle
{
---
}
package com.oracle.jdbc;
public class OracleConnectionImpl implements Connection// Oracle
{
----
public Statement createStatement()
{
--------
Statement st=new OracleStatementImpl();
return st;
}
}
class JdbcApp
{
public static void main(String[] args)
{
-------
Statement st=con.createStatement();
}
}
PreparedStatement: To execute the same sql query in the next sequence, where to
improve JDBC application performance.
C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc6.jar
DDL:create, alter, drop
int rowCount=st.executeUpdate(insert/update/delete)
int rowCount=st.executeUpdate(create/alter/drop);
Here internally ResultSet object is created but it will return true value.
Here internally RowCount value is created but it will return false value.
st.executeQuery(--)
st.executeUpdate(--)
st.execute(--)
Q)In JDBC, we will use executeQuery(--) method to execute select sql query, but, if
we provide non-select sql query as parameter to executeQuery(--) method then what
will happen in JDBC applications?
-----------------------------------------------------------------------
Q)In JDBC, we will use executeUpdate(--) method to execute non-select sql query,
but, if we provide select sql query as parameter to executeUpdate(--) method then
what will happen in JDBC applications?
-----------------------------------------------------------------------
int rowCount=st.executeUpdate("select * from emp1");
If we want to use the above driver classs in Jdbc applications then we have to set
"classpath" environment variable to
"mysql-connector-java-5.0.8-bin.jar" or we have to add this jar file to our project
in eclipse ide as referenced library.
To prove Scroll sensitive ResultSet object we have to use the following steps.
1.Create Scroll Sensitive ResultSet.
2.Display Data from ResultSet object.
3.Pause application , goto database and perform modifications on table
explicitly.
4.Re-display data from ResultSet object by refreshing each and every record.
Conclusion: If the data before updatinos and after updations is different then the
ResultSet object is scroll sensitive ResultSet.
Updatable ResultSets:
----------------------
--> We can perform the database operations like insert, update, delete with out
using the respective SQL Queries.
--> We will use this mechanism when we have a requirement to work with unknown
databases.
Batch Updations:
-----------------
public void addBatch(String sql_Query)
CallableStatement:
-------------------
Procedure will not have return statement to return value.
EX:
----
create or replace procedure Procedure_Name[(Param_List)]
AS
---Global declarations-----
BEGIN
----Database Logic----
END Procedure_Name;
/---> to save and compile procedure.
2.OUT type parameters: It will take values from procedure/function body and it will
send to procedure/function call.
CallableStatement.
CURSOR types.
SYS_REFCURSOR
Metadata:
---------
Data about the data is called Metadata.
1.DatabaseMetaData
2.ResultSetMetaData
1.DatabaseMetaData
--------------------
Database name,Database Product version, Driver versions, Supported SQL Keywords,
String Functions, NUmeric Functions, ......
2.ResultSetMetaData
--------------------
data about ResultSet is called as ResultSet metadata, it includes no of columns,
column names, column data types, column sizes,.......
Transaction Management:
------------------------
Front-End appl on Back-End system
Withdraw, deposit, transfer,.......Transactions.
In general, all transactions must follow the following properties called as "ACID"
properties
A-----> Automicity
C-----> COnsistency
I-----> Isolation
D-----> Durability
Automicity:
-----------
Either perform all operations or perform none of the operations in Transaction.
Perform All----> SUCCESS
Perform None---> FAILURE
1.Automicity:
---------------
Savepoint
----------
Isolation Levels:
------------------
java.sql.Connection
con.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
public int getTransactionIsolation()
BLOB CLOB
RowSets
Connection Pooling
-------------------
BLOB CLOB
------------
BLOB
----
It is a data type in databases, it able to manage large volumes of binary data and
it able to manage Images data,...
CLOB
----
It is a data type in databases, it able to manage large volumes of characters data
and it able to manage Documents like .doc files, PDFs, XML docs,.....
RowSets:
---------
1.JdbcRowSet
2.CachedRowSet
---------------------------------------------
Servlets:
----------
1.Standalone Appl
1.CUI Appl
2.GUI Appl
2.Enterprise Appl
1.Web Appl
2.Distributed Appl
Q)What are the differences between Web applications and Distributed Applications?
-----------------------------------------------------------------------
Ans:
----
1.In case of web applications, the complete application logic is distributed over
server machine only.
2.To prepare Web applications we will use a set of technologies called as "Web
tech"
EX: CGI
Servlets
JSPs
----
----
To prepare Distributed Applications, we will use a set of tech called as
"Distributed technologies".
EX: Socket Programming
RMI
CORBA
EJBs
Web Services
----
----
3.In case of Web applications, client is fixed that is Browser.
In case of Distributed Applications, client may be a core java program with main()
method, a GUI application with actionPerformed(--), a servlet program, a JSP
application, a struts appl, a JSF appl, A spring web module,.....
4.In case of web applications, Server saide application will provide services for
only one type of client that is browser.
In case of Distributed applications, server side appl may provide services for any
type of client.
5.The main purpose of web applications is to generate dynamic response from Server
machine.
7.Web application is the collection of web components like servlets, JSPs, which
are executed by the web containers like servlet container and JSP container,...
Distributed application is the collection of Distributed components like EJBs,
which are execurted by EJB Container.
-------------------------------------------------------------------------
In Enterprise Appl, there are two types of responses.
1.Static Response
2.Dynamic Response
2.In Web applications, we will use servlets mainly for processing the
requests[Executing Business Logic].
JSPs are maily for presentation part.
3.IN MVC based web applications, we have to use a servlet as controller and a set
of JSP pages as view part.
4.If we use only Servlets in web applications then we are unable to seperate
business logic and presentation logic.
If we use only JSPs in web applications, we are able to seperate presentation logic
and Business logic, for presentation logic we are able to use Html tags and for
Busines logic we are able to use JSP tags.
Client-Server Arch:
--------------------
It is 2-Tier Arch, it is minimum arch for enterprise appl , that is , web
applications.
1.Client
2.Protocol
3.Server
1.Client
----------
--> Client is a browser.
--> The role of the client in client-server arch is to send requests to server and
to get response from server.
--> To send request or to refer a particular serve4r side resource we have to use a
String at client address bar called as "URI".
1.URN
2.URL
Syntax:
-------
Protocol_Name://Server_IP_Addr:Server_Port_Num/appl_Name/res_Name[?Query_
String]
EX:
---
http://localhost:8080/loginapp/login?uname=abc&upwd=abc123
http----> Protocol_Name
localhost --> Server IP Address,If server software is available at the same client
machine then we can specify "localhost" as server IP address.
"127.0.0.1"
8080---> Server Port Number
8080 ---> Tomcat
7001 ---> Weblogic
--- ----
loginapp---> Web application name
login------> Locator for Login Servlet
?uname=abc&upwd=abc123 ----> Query String
http://localhost:8080/loginapp/login?uname=abc&upwd=abc123
------------------------------------------------------------------------
2.Protocol:
-------------
Hyd to Mumbai.
1.Bus: a Protocol.
2.Train: a protocol
3.Air: a protocol
Q)In web applications we are going to use only Http protocol why?
------------------------------------------------------------------
Ans:
----
In web applications, we need a protociol, it must be ,
1.Connection less protocol: Not to have any phisical connection, to have
logical connection.
2.Stateless Protocol: Not to remembers previous requests data at the time
of processing present request.
3.Compatible with Hypertext data:In general , Data will be transfered from client
to server and from server to client in the form of Hyper text only
Http protocol
Protocol Services
-----------------
1.Http Methods
2.Status Codes
1.Http Methods
---------------
Http1.0
-------
GET
POST
HEAD
Http1.1
--------
OPTIONS
PUT
TRACE
DELETE
CONNECT
Q)What are the differences between GET and POST?
--------------------------------------------------
Ans:
----
1.GET request type is default request in web applications.
POST requyest type is not default requests type.
3.GET Request is able to transfer less data from client to server due to the lack
of Body part in Request Format.
POST request is able to transfer more data from client to server due to the
availability of the body part.
Note: If we submit data along with GET request then that data will be transfered
through Header part of the request format, where header part is having memory
restrictions over the data , it allows only 2048 characters data only.No memory
restrictions over the data in POSt request.
4.In case of GET request no security is available for the Data like password data,
PIN Numbers,...
In case of POST request , Security is availabl for the data like Password data,PIN
Numbers, Secreate codes,....
Note:IN case of GEt request, If we provide data along with request then that data
will be displayed on client address bar as query string.In case of POST request, if
we provide data along with request then that data is not visible on client address
bar.
5.The main purpose of GET is to get data from Server , that is , for Downloading
data from Server.
The main purponse of POST request is POST data to Server , that is, for Uploading
Data to the Server.
4.OPTIONS:
----------
It can be used to get the HTTP method which are supported by present Server.
5.PUT :
-------
It is also be used to POST the data , but, it is used mainly for replacement of
tyhe resources at server.
6.DELETE:
----------
It can be used to specify a particular resource to delete from Server.
7.TRACE:
--------
To know the tracing part of the resource path we need to use TRACE request. It can
be used to check whether resources are working fine or not which are available at
server. It working on the basis of Echo server nature.
PUT, DELETE request types are not supported almost all the servers.
---------------------------------------------------------------------
Status Codes:
--------------
1XX ---> 100 to 199 ----> Informational Status Codes
2XX ---> 200 to 299 ----> Success Related Status codes.
3XX ---> 300 to 399 ----> Redirectinoal status codes.
4XX ---> 400 to 499 ----> Client Side Error.
5XX ---> 500 to 599 ----> Server Side Error.
Protocol:
----------
What is protocol
Which protocol is required in web appl.
What is the requirement to use Http Protocol.
How Http Protocol is able to manage its stateless nature.
Http Methods
Status Codes.
-------------------------------------------------------------------------
Server:
--------
Getting requests from client, Processing request and sending response to the
client.
Server softwares.
Tomcat
Weblogic
Websphere
JBOSS/Wildfly
Glassfish
----
----
2 types
1.Web Servers
2.Application Servers
1.Main Server
2.Container
Container: It will take request from Mian Server, It will identify requested
resource, executes that requested resource and generates response to Main server.
2.on the basis of the containers physical existency there are three types of
containers.
1.Standalone Container:It is an integration of Main Server and
Container as single unit.
2.In-Process Container: It is a container existed inside the main
server.
3.Out-Of-Process Container:It is a container existed in out side of the
Main Server.
-------------------------------------------------------------------------
http://localhost:1010/loginapp/login
<web-app>
<servlet>
<servlet-name>servlet_logical_name</servlet-name>
<servlet-class>Servlet class Fully Qualified Name</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>servlet_logical_name</servlet-name>
<url-pattern>pattern_Name1</url-pattern>
<url-pattern>pattern_Name2</url-pattern>
-----
</servlet-mapping>
</web-app>
EX:
---
<web-app>
<servlet>
<servlet-name>loginServlet</servlet-name>
<servlet-class>com.durgasoft.LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>loginServlet</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
</web-app>
Servlet2.5 version onwards we can declare more than one URL Pattern for Single
Servlet.
http://localhost:1010/loginapp/login
There are three approaches to define URL Patterns in web applications for Servlets.
<url-pattern>/abc/xyz</url-pattern>
Provide an url pattern at Client Address bar, it must be matched with the URL
pattern which we specified in web.xml file.
http://localhost:1010/app1/abc/xyz----> Valid
http://localhost:1010/app1/xyz/abc---> Invalid
http://localhost:1010/app1/abc-------> Invalid
http://localhost:1010/app1/xyz-------> Invalid
Note: When we want to access servlets individually there we have to use Exact match
method.
<url-pattern>/abc/*</url-pattern>
Note: When we want to send gropups of requests to the server side resources there
we have to use directory match method to defined url pattern.
EX: Filters
<url-pattern>*.do</url-pattern>
http://lh:1010/app1/login.do-----> Valid
http://lh:1010/app1/reg.do-------> Valid
http://localhost:1010/add.do-----> Valid
http://localhost:1010/search.do----> Valid
http://localhost:1010/delete.xyz----> INvalid
It will be used in MVC based applications, where we need to send all the requests
to the Controller , where we have to perform actions on the basis of the url
patterns.
1.Using Servlet/Filter/Listeners
---------------------------------
In all servers, web.xml file is mandatory upto Servlet2.5 version, web.xml file
optional from Servlets3.0 version, because, Servlet3.0 version will use Annotations
inplace of web.xml file.
In javax.servlet
Servlet
GenericServlet
In javax.servlet.http
HttpServlet
Q)What is Servlet and in how many ways we are able to prepare Servlets in web
applications?
-------------------------------------------------------------------------
Ans:
----
Serlvet is a server side program managed by the container , it can be executed to
generate dynamic response.
As per the predefined library , there are three ways to porepare Servlets.
http://localhost:1010/app1/abc
------------------------------------------------------------------
Servlets Design:
-----------------
There are three ways to prepare Servlets
1.Implementing Servlet interface
2.Extending GenericServlet abstract class
3.Extending HttpServlet abstract class
2.Extending GenericServlet
-----------------------------
In this approach, we have to declare an user defined class , it must be extended
from javax.servlet.GenericServlet .
Q)In Servlets, is it possible to provide both constructor and init() method with in
a single Servlet class?
-----------------------------------------------------------------------
Ans:
----
In Servlets, we can write constructor and init() both with in a single Servlet
class. If we provide static block, constructor, init() method, service() or doXXX()
method and destroy method with in a single servlet then container will execute all
the programming element at the following respective servlet life cycle actions.
Lifecycle:
-----------
IN web applications, we are able to generate forms in the following two ways.
http://localhost:1010/loginapp/loginform.html
http://localhost:1010/reg_app/get_update_Form
When form is generated at client, when we submit request with data from user form
to Server , at server machine the user specified data will be stored in Request
object.
To get the value of a particular request parameter on the basis of key we have to
use the following method.
If multiple values are associated with single key and if we want to get that
associated value in the form of an array we have to use the following method.
To get only keys , not values then we have to use the following method.
ServletContext:
----------------
Q)What are the differences between ServletConfig and ServletContext?
--------------------------------------------------------------------
Ans:
----
1.ServletConfig object is able to manage all the configuration details of a
particular servlet which includes logical name of the Servlet, initialization
parameters,..... which we specified in web.xml file.
ServletContext object is able to manage all the context details of a particular web
application which includes logical name of the web application, context
parameters,..... which we specified in web.xml file.
3.If we keep data in ServletConfig object then that data will be shared upto a
particular Servlet.
If we keep data in ServletContext object then that data will be shared through out
the web application.
8.The lifetime of the ServletConfig object is upto the Servlet object lifetime.
9.ServletConfig object is able to allow only parameters data, that is, static data.
ServletContext object is able to allow both parameters data and attributes data,
that is , both static data and dynamic data.
10.ServletConfig object will be created after the server startup and after getting
first request from client except in <load-on-startup> configuration.
ServletContext context=getServletContext();
ServletContext context=request.getServletContext();
<web-app>
---
<display-name>logical_name</display-name>
----
</web-app>