0% found this document useful (0 votes)
7 views4 pages

Wip Unit 3

The document provides an overview of servlets, including their definition, applications, and interaction with web servers. It discusses advantages and disadvantages, session tracking methods, and differentiates between GET and POST requests. Additionally, it covers cookies, JDBC, and includes programming tasks related to servlet database connectivity and session management.

Uploaded by

priya j
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Wip Unit 3

The document provides an overview of servlets, including their definition, applications, and interaction with web servers. It discusses advantages and disadvantages, session tracking methods, and differentiates between GET and POST requests. Additionally, it covers cookies, JDBC, and includes programming tasks related to servlet database connectivity and session management.

Uploaded by

priya j
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Unit3:

1) What are servlets?


A servlet is a Java programming language class that is used to extend the capabilities
of servers that host applications accessed by means of a request-response programming
model

2) Write application of servlet


Read the explicit data sent by the clients
Read the implicit HTTP request data sent by the clients
Process the data and generate the results

3) Summarize briefly about the interaction between a webserver and a servlet.


The servlet doesn't talk to the client directly. The Web server does that. In a chain of
processes, the client sends a request to the Web server, which hands it to the container, which
hands it to the servlet

4) Summarize the advantages and disadvantages of servlets.


Advantages:
Better performance: because it creates a thread for each request, not process.

Portability: because it uses Java language.

Disadvantages:

Servlet is persistent until it destroys.

Designing in a servlet is difficult and slows down the application.

5) Show how is session tracking is achieved by the URL rewriting?


With URL rewriting, all links that are returned to the browser or that get redirected
have the session ID appended to them. When the user clicks these links, the rewritten form of
the URL is sent to the server as part of the client request.
6) Differentiate GET and POST request type.

HTTP GET request HTTP POST request


doGet() method is used doPost() method is used
URL string displays request URL string does not display
submitted by the user request submitted by user
To download info from server To upload info from server
No effect on data Has effect on data
Page can be bookmarked Page cannot be bookmarked
page can be cached, saved Page cannot be cached,
in history cannot be saved in history
Only ASCII characters Any character is allowed
allowed
Unsafe More secure

7) Summarize the servlet interface and its methods.


The Servlet interface defines methods to initialize a servlet, to receive and respond to
client requests, and to destroy a servlet and its resources. These are known as life-cycle
methods. They are
 init(), service(), destroy()
Phases:-
 Phase 1: Servlet class is loaded
 Phase 2: Servlet instance is created
 Phase 3: Init() method is invoked
 Phase4: service() method is invoked
 Phase5:destroy() method is invoked

8) What is cookie?
A cookie is a piece of data from a website that is stored within a web browser that the
website can retrieve at a later time. Cookies are used to tell the server that users have returned
to a particular website.
10) What is the purpose of cookie?
Cookies make the interaction between users and websites faster and easier. Without
cookies, it would be very difficult for a website to allow a visitor to fill up a shopping cart or
to remember the user's preferences or registration details for a future visit.

11) Quote the uses of cookies


Identifying the user during ecommerce
Avoid username and password
Customize the website as we want
Focusing on advertising webpages
12) What is the purpose of url rewriting?
URL rewriting allows URLs to be more easily remembered by the user. When the
URL is entered into the Web server, the URL rewrite engine modifies the syntax behind the
scenes to enable the appropriate Web page or database item to be retrieved.

13)State the use of ServletContext object.


Defines a set of methods that a servlet uses to communicate with its servlet container, for
example, to get the MIME type of a file, dispatch requests, or write to a log file.
14) Define JDBC
JDBC stands for Java Database Connectivity. JDBC is a Java API to connect and execute
the query with the database. It is a part of JavaSE (Java Standard Edition). JDBC API uses
JDBC drivers to connect with the database. There are four types of JDBC drivers:
o JDBC-ODBC Bridge Driver,
o Native Driver,
o Network Protocol Driver, and
o Thin Driver

15) Define Hidden Form Fields?


 A hidden text field is used for maintaining the state of a user
 Here, information is stored in hidden field
 It is better if we want to submit form in all the pages and we don’t depend on the browser
 Ex: <input type=”hidden” name=”sid” value=”abc123”>

Part B:(16m)

1) Integrate how servlet work and its life cycle.


2) Explain and develop the Servlet API.
3) Demonstrate the Servlet architecture and explain its working principle.(16M)
4) Describe in detail the session handling in server side programming.(OR) What is a
session? Explain how client state is maintained using session and also explain about session
tracking and session management using an example.
5) Explain the use of cookies for tracking with a program.(OR) Write a servlet to illustrate
the principle of Cookies and explain.(OR) Discuss the ways of storing and accessing
information using cookies and handling associated issues.
6) Explain multi tier application(JDBC) with example

PROGRAM:
1)* Consider a database that has a table Employee with two columns Employee Id and Name.
Assume that the administrator user id and password to access to access the database table are
Scott and Tiger.Write a JDBC program that can query and print all entries in the
table employee. Make the database using type 2 driver database.driver and connection string
jdbc :db.oci.

2) *Explain in detail about Servlet database connectivity with an example of student


database.

3) Write a Java Servlet to display net salary of employee, use JDBC connectivity to get
employee details from database
4) Write a Java code for getting the details of the items to be purchased from a client and to
update the inventory of the shop after selling. Also bill should be prepared for the client.
Maintain the transaction table also just by inserting these purchase item details at the shop
use JDBC for transactions.

5) *Evaluate a complete query application for books database using JDBC.

6) *Write a program that allows the user to select a favourite programming language and post
the choice to the server. The response is a web page in which the user can click a link to view
a list of book recommendations. The cookies previously stored on the client are read by the
servlet and form a web page containing the book recommendation. Use servlet cookies and
HTML.

6) Write a code to display the current and yesterday’s gold rate using session object

You might also like