1 CHAPTER 3 TRAINING ATTENDED 3.1 Introduction I have done my training from HCL INFOSYSTEMS LTD. located at Sitapura, Jaipur (Raj.) I have done my training in Advance Java and explore the following topics –Java Database Connectivity (JDBC) Servlets Java Server Pages (JSP) 3.2 Exposure Level I explore many topics of Advance Java like JDBC, Swings, JSP, Sockets etc. I primarily focus on the topics related to web application and here I explain some of the web development related topics. 3.2.1 Java Database Connectivity (JDBC) The JDBC (Java Database Connectivity) API defines interfaces and classes for writing database applications in Java by making database connections. Using JDBC we can send SQL, PL/SQL statements to almost any relational database. JDBC is a Java API for executing SQL statements and supports basic SQL functionality. It provides RDBMS access by allowing we to embed SQL inside Java code. Because Java can run on a thin client, applets embedded in Web pages can contain downloadable JDBC code to enable remote database access. Although JDBC was designed specifically to provide a Java interface to relational databases, we may find that we need to write Java code to access non-relational databases as well.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
8/4/2019 Dewang Final
http://slidepdf.com/reader/full/dewang-final 1/29
1
CHAPTER 3
TRAINING ATTENDED
3.1 Introduction
I have done my training from HCL INFOSYSTEMS LTD. located at Sitapura,
Jaipur (Raj.) I have done my training in Advance Java and explore the following topics –
Java Database Connectivity (JDBC)
Servlets
Java Server Pages (JSP)
3.2 Exposure Level
I explore many topics of Advance Java like JDBC, Swings, JSP, Sockets etc. I
primarily focus on the topics related to web application and here I explain some of the web
development related topics.
3.2.1 Java Database Connectivity (JDBC)
The JDBC (Java Database Connectivity) API defines interfaces and classes forwriting database applications in Java by making database connections. Using JDBC we can
send SQL, PL/SQL statements to almost any relational database. JDBC is a Java API for
executing SQL statements and supports basic SQL functionality. It provides RDBMS
access by allowing we to embed SQL inside Java code. Because Java can run on a thin
client, applets embedded in Web pages can contain downloadable JDBC code to enable
remote database access.
Although JDBC was designed specifically to provide a Java interface to relational
databases, we may find that we need to write Java code to access non-relational databases
as well.
8/4/2019 Dewang Final
http://slidepdf.com/reader/full/dewang-final 2/29
2
Figure 3.1
JDBC Architecture
Java application calls the JDBC library. JDBC loads a driver which talks to the database.
We can change database engines without changing database code.
3.2.1.1 Types of JDBC Drivers
Driver types are used to categorize the technology used to connect to the database.
A JDBC driver vendor uses these types to describe how their product operates.
Some JDBC driver types are better suited for some applications than others. There
are four types of JDBC drivers as shown in the table below –
Table 3.1
JDBC Drivers Types
Driver Category All Java? Net Protocol
1 – JDBC ODBC Bridge No Direct
2 – Native API as basis No Direct
3 – JDBC – Net Yes Require Connector
4 – Native Protocol as basis Yes Direct
1. Type 1 Driver - JDBC-ODBC bridge
The JDBC type 1 driver, also known as the JDBC-ODBC Bridge, is a databasedriver implementation that employs the ODBC driver to connect to the database. The
driver converts JDBC method calls into ODBC function calls.
The driver is platform-dependent as it makes use of ODBC which in turn
depends on native libraries of the underlying operating system the JVM is running
upon. Also, use of this driver leads to other installation dependencies; for example,
ODBC must be installed on the computer having the driver and the database must
support an ODBC driver. The use of this driver is discouraged if the alternative of a
8/4/2019 Dewang Final
http://slidepdf.com/reader/full/dewang-final 3/29
3
pure-Java driver is available. The other implication is that any application using a type
1 driver is non-portable given the binding between the driver and platform. This
technology isn't suitable for a high-transaction environment. Type 1 drivers also don't
support the complete Java command set and are limited by the functionality of the
ODBC driver.
Figure 3.2
Schematic of the JDBC-ODBC Bridge
Functions
Translates query obtained by JDBC into corresponding ODBC query, which
is then handled by the ODBC driver.
Sun provides a JDBC-ODBC Bridge driver as
sun.jdbc.odbc.JdbcOdbcDriver. This driver is native code and not
Since the communication between client and the middleware server is database
independent, there is no need for the vendor db library on the client machine.
Also the client to middleware need not be changed for a new database.
The Middleware Server (which can be a fully fledged J2EE Application server)can provide typical middleware services like caching (connections, query
results, and so on), load balancing, logging, auditing etc.
Can be used in internet since there is no client side software needed.
At client side a single driver can handle any database. (It works provided the
middleware supports that database!)
Disadvantages
Requires database-specific coding to be done in the middle tier.
An extra layer added may result in a time-bottleneck. But typically this isovercome by providing efficient middleware services.
4. Type 4 Driver - Native-Protocol Driver
The JDBC type 4 driver, also known as the Direct to Database Pure Java
Driver, is a database driver implementation that converts JDBC calls directly into a
vendor-specific database protocol. Therefore it is called a THIN driver.
Written completely in Java, type 4 drivers are thus platform independent.They install inside the Java Virtual Machine of the client. This provides better
performance than the type 1 and type 2 drivers as it does not have the overhead of
conversion of calls into ODBC or database API calls. Unlike the type 3 drivers, it
does not need associated software to work.
As the database protocol is vendor-specific, the JDBC client requires
separate drivers, usually vendor-supplied, to connect to different types of databases.
8/4/2019 Dewang Final
http://slidepdf.com/reader/full/dewang-final 8/29
8
Figure 3.5
Schematic of Native-Protocol driver
Functions
Type 4 drivers, coded entirely in Java, communicate directly with a vendor'sdatabase, usually through socket connections. No translation or middleware
layers are required, improving performance.
The driver converts JDBC calls into the vendor-specific database protocol so
that client applications can communicate directly with the database server.
Completely implemented in Java to achieve platform independence.
This type includes (for example) the widely-used Oracle thin driver -
oracle.jdbc.driver.OracleDriver which connects using a
These drivers don't translate the requests into an intermediary format (such
as ODBC), nor do they need a middleware layer to service requests. This
can enhance performance considerably.
The JVM can manage all aspects of the application-to-database connection;
this can facilitate debugging.
Provides a way to manage copies of the database for each user.
Disadvantages
Drivers are database dependent.
3.2.2 Servlets
A servlet is a Java programming language class used to extend the capabilities of
servers that host applications accessed via a request-response programming model.
Although servlets can respond to any type of request, they are commonly used to extend theapplications hosted by Web servers. Thus, it can be thought of as a Java Applet that runs on
a server instead of a browser.
A Servlet is a Java class in Java EE that conforms to the Java Servlet API, a
protocol by which a Java class may respond to requests. They are not tied to a specific
client-server protocol, but are most often used with the HTTP protocol. Therefore, the word
"Servlet" is often used in the meaning of "HTTP Servlet". Thus, a software developer may
use a servlet to add dynamic content to a Web server using the Java platform. The
generated content is commonly HTML, but may be other data such as XML. Servlets are
the Java counterpart to non-Java dynamic Web content technologies such as CGI andASP.NET. Servlets can maintain state in session variables across many server transactions
by using HTTP cookies, or URL rewriting.
To deploy and run, the Apache Tomcat Server may be used. It is an open source
servlet container developed by the Apache Software Foundation (ASF). Tomcat
implements the Java Servlet and the Java Server Pages (JSP) specifications from Sun
Microsystems, and provides a "pure Java" HTTP web server environment for Java code to
run.
The servlet API, contained in the Java package hierarchy javax.servlet,defines the expected interactions of a Web container and a servlet. A Web container is
essentially the component of a Web server that interacts with the servlets. The Web
container is responsible for managing the lifecycle of servlets, mapping a URL to a
particular servlet and ensuring that the URL requester has the correct access rights.
A Servlet is an object that receives a request and generates a response based on that
request. The basic servlet package defines Java objects to represent servlet requests and
responses, as well as objects to reflect the servlet's configuration parameters and execution
environment. The package javax.servlet.http defines HTTP-specific subclasses of
the generic servlet elements, including session management objects that track multiple
requests and responses between the Web server and a client. Servlets may be packaged in a
WAR file as a Web application.
Servlets can be generated automatically from Java Server Pages (JSP) by the Java ServerPages compiler. The difference between Servlets and JSP is that Servlets typically embed
HTML inside Java code, while JSPs embed Java code in HTML. While the direct usage of
Servlets to generate HTML is relatively rare nowadays, the higher level MVC web
framework in Java EE (JSF) still explicitly uses the Servlet technology for the low level
request/response handling via the FacesServlet. A somewhat older usage is to use servlets
in conjunction with JSPs in a pattern called "Model 2", which is a flavor of the model-
view-controller pattern.
Table 3.2
Servlet API History
Servlet API
version
Released Platform Important Changes
Servlet 3.0 December
2009
JavaEE 6,
JavaSE 6
Pluggability, Ease of development, Async
Servlet, Security, File Uploading
Servlet 2.5 September
2005
JavaEE 5,
JavaSE 5
Requires JavaSE 5, supports annotation
Servlet 2.4 November
2003
J2EE 1.4,
J2SE 1.3
web.xml uses XML Schema
Servlet 2.3 August 2001 J2EE 1.3,J2SE 1.2
Addition of Filter
Servlet 2.2 August 1999 J2EE 1.2,
J2SE 1.2
Becomes part of J2EE, introduced
independent web applications in .war files
Servlet 2.1 November
1998
Unspecified First official specification, added
RequestDispatcher, ServletContext
Servlet 2.0 JDK 1.1 Part of Java Servlet Development Kit 2.0
Servlet 1.0 June 1997 Undefined
3.2.2.1 Life cycle of a Servlet
1. The container calls the no-argument constructor.
2. The Web container calls the init() method. This method initializes the servlet and
must be called before life of a servlet, the init() method is called only once.
3. After initialization, the servlet can service client requests. Each request is serviced
in its own separate thread. The Web container calls the service() method of the
Process or store data that was submitted from an HTML form.
Provide dynamic content such as the results of a database query.
Manage state information that does not exist in the stateless HTTP protocol, such as
filling the articles into the shopping cart of the appropriate customer.
3.2.3 Java Server Pages (JSP)
Architecturally, JSP may be viewed as a high-level abstraction of Java servlets. JSP
pages are loaded in the server and are operated from a structured special installed Javaserver packet called a Java EE Web Application, often packaged as a .war or .ear file
archive.
JSP allows Java code and certain pre-defined actions to be interleaved with static
web markup content, with the resulting page being compiled and executed on the server to
deliver an HTML or XML document. The compiled pages and any dependent Java libraries
use Java byte code rather than a native software format, and must therefore be executed
within a Java virtual machine (JVM) that integrates with the host operating system to
provide an abstract platform-neutral environment.
JSP syntax is a fluid mix of two basic content forms: scriptlet elements and markup.
Markup is typically standard HTML or XML, while scriptlet elements are delimited blocks
of Java code which may be intermixed with the markup. When the page is requested the
Java code is executed and its output is added, in situ, with the surrounding markup to createthe final page. JSP pages must be compiled to Java byte code classes before they can be
executed, but such compilation is needed only when a change to the source JSP file has
occurred.
Java code is not required to be complete (self contained) within its scriptlet element block,
but can straddle markup content providing the page as a whole is syntactically correct (for
example, any Java if/for/while blocks opened in one scriptlet element must be correctly
closed in a later element for the page to successfully compile). This system of split inline
coding sections is called step over scripting because it can wrap around the static markup
by stepping over it. Markup which falls inside a split block of code is subject to that code,so markup inside an if block will only appear in the output when the if condition evaluates
to true; likewise markup inside a loop construct may appear multiple times in the output
depending upon how many times the loop body runs.
The JSP syntax adds additional XML-like tags, called JSP actions, to invoke built-
in functionality. Additionally, the technology allows for the creation of JSP tag libraries
that act as extensions to the standard HTML or XML tags. JVM operated tag libraries
provide a platform independent way of extending the capabilities of a web server. Note that
not all commercial Java servers are Java EE specification compliant.
To simplify code in JSP expressions and scriptlets, you are supplied with nine
automatically defined variables, sometimes called implicit objects.
The available variables are shown in the Table 3.3.
Systems analysis is a process of collecting factual data, understand the processes
involved, identifying problems and recommending feasible suggestions for improving the
system functioning. This involves studying the business processes, gathering operational
data, understand the information flow, finding out bottlenecks and evolving solutions for
overcoming the weaknesses of the system so as to achieve the organizational goals. SystemAnalysis also includes subdividing of complex process involving the entire system,
identification of data store and manual processes.The major objectives of systems analysis
are to find answers for each business process –
What is being done.
How is it being done.
Who is doing it.
When is he/she doing it.
Why is it being done.
How can it beimproved?
It is more of a thinking process and involves the creative skills of the System
Analyst. It attempts to give birth to a new efficient system that satisfies the current needs of
the user and has scope for future growth within the organizational constraints. The result of
this process is a logical system design. Systems analysis is an iterative process that
continues until a preferred and acceptable solution emerges.
4.5 System Design
Based on the user requirements and the detailed analysis of the existing system, the
new system must be designed. This is the phase of system designing. It is the most crucial
phase in the developments of a system. The logical system design arrived at as a result of
systems analysis is converted into physical system design. Normally, the design proceeds in
two stages -
Preliminary or General Design
Structured or Detailed Design
Preliminary or General Design - In the preliminary or general design, the features of thenew system are specified. The costs of implementing these features and the benefits to be
derived are estimated. If the project is still considered to be feasible, we move to the
detailed design stage.
Structured or Detailed Design - In the detailed design stage, computer oriented work
begins in earnest. At this stage, the design of the system becomes more structured.
Structure design is a blue print of a computer system solution to a given problem having the
The code is tested at various levels in software testing. Unit, system and user
acceptance testing are often performed. This is a grey area as many different opinions exist
as to what the stages of testing are and how much if any iteration occurs. Iteration is notgenerally part of the waterfall model, but usually some occur at this stage. In the testing the
whole system is test one by one.
Following are the types of testing -
Path testing
Data set testing
Unit testing
System testing
Integration testing
Black box testing
White box testing
Regression testing
Automation testing
User acceptance testing
Performance testing
4.7.2 Operations and maintenance
The deployment of the system includes changes and enhancements before the
decommissioning or sunset of the system. Maintaining the system is an important aspect of
SDLC. As key personnel change positions in the organization, new changes will be
implemented, which will require system updates.
4.8 Conclusion
The various phases of the project were successfully completed. It‟s a great
experience on working on one of the live project of a company like HCL. While
implementing the various phases I got the practical knowledge of the topics which I havebeen taught theoretically as System Development Life Cycle.