13
A JSP container works with the Web server to provide the runtime environment and other
services a JSP needs
A typical request / response phase of a JSP is defined below
a) Request is initiated for a jsp file by client using browser
b) Webs server (JSP engine) loads the JSP file and translate the JSP file into a java code . The Generated
Java code will be a Servlet.
c) Once Servlet (Java code ) is generated, JSP engine compiles the servlet. Any compilation errors will be
detected in this phase.
d) Now servlet class is loaded by the container and executes it.
e) JSP Engine sends the response back to client.
Translation and compilation phase is done only when
a) First request came for the jsp file
b) The generated servlet is older than the JSP file. This is the case when JSP file is modified
20.(b)(ii) Discuss JSP vs JavaScript.[5]
JSP versus java script
Sno.
JSP
Java script
1
It is executed by the server which
hosts the site
It is executed by the browser on our
local machine.
2
It is server side scripting which
enables us to write code in java and
do perform database interaction etc.
It is client side scripting language
which is used to interact with the
client at front end ie browser.
3
JSP uses full java technology
Java script uses little java technology
21.(a). Explain about crating connection and statement with operations in MySQL in detail. [10]
Creating connection
Database can be accessed only after creating connection object. Before creating connection a
driver must be loaded and registered.
The general function used to create connection is
getConnection()
DriverManager provides three methods for creating connections:
getConnection(String url)
getConnection(String url, String userID, String password)
getConnection(String url, Properties prop)
The driver manager maintains a list of registered drivers. When its getConnection() method is
invoked, it checks each driver whether it will accept the specified URL. The driver manager do this by
calling the driver„s connect() method, which returns null if the driver cannot accept the URL or an active
Connection object if it accept the URL.
Creating statement