You are on page 1of 4

Fikre Belachew 097/11

Sebiredin Hussen 115/11

Kaleab Alemayehu 103/11

Tariku Tigabu 116/11

Waleligni Tadesse 122/11

Firehiwot Imiru 098/11

Abuye tewabe 126/11

Answer for group one questions


 Define a Servlet
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.
Although servlets can respond to any type of request, they are commonly used to extend the
applications hosted by web servers. For such applications, Java Servlet technology defines
HTTP-specific servlet classes.

 List the advantages of using servlets


 Better performance: because it creates a thread for each request, not process.
 Portability: because it uses Java language.
 Robust: JVM manages Servlets, so we don't need to worry about the memory
leak, garbage collection, etc.
 Secure: because it uses java language.
 Portability
As we know that the servlets are written in java and follow well known standardized
APIs so they are highly portable across operating systems and server implementations.
 Powerful
we can do several things with the servlets which were difficult or even impossible to do
with CGI, for example the servlets can talk directly to the web server while the CGI
programs can't do. Servlets can share data among each other, they even make the
database connection pools easy to implement.
 Efficiency
As compared to CGI the servlets invocation is highly efficient. When the servlet get
loaded in the server, it remains in the server's memory as a single object instance.
However with servlets there are N threads but only a single copy of the servlet class.
 Integration
Servlets are tightly integrated with the server. Servlet can use the server to translate the
file paths, perform logging, check authorization, and MIME type mapping etc
 Safety
As servlets are written in java, servlets inherit the strong type safety of java language.
Java's automatic garbage collection and a lack of pointers means that servlets are
generally safe from memory management problems. In servlets we can easily handle the
errors due to  Java's exception handling mechanism. If any exception occurs then it will
throw an exception.
 Extensibility
The servlet API is designed in such a way that it can be easily extensible. As it stands
today, the servlet API support H
 Inexpensive
There are number of  free web servers available for personal use or for commercial
purpose. Web servers are relatively expensive. So by using the free available web
servers you can add servlet support to it.ttp Servlets, but in later date it can be extended
for another type of servlets.
 Client/Server Communication
Client/Server communication involves two components, namely a client and a server. They
are usually multiple clients in communication with a single server. The clients send requests to
the server and the server responds to the client requests.

A client is whatever you’re using to interact with the internet. It’s the web browser you’re using to read
this page. The web browser on your computer is one client, the web browser on your phone is another
client. There are other types of clients (like the Netflix app on your phone, or the Spotify application on
your computer), but we’ll focus on web browsers for now.

A server is a computer that responds to requests by serving responses.

 Use a servlet to access a database


To access the database in Servlet, load the JDBC driver and return the Connection object.
The Connection object is used to create Statement object. Before starting with database access
through servlet, make sure that the proper JDBC connection with database has been setup.

Servlets are mainly used in Dynamic web applications which provide dynamic
responses to client requests. In most cases, Dynamic web applications access
a database to provide the client requested data. We can use Java standard
database connection – JDBC in Servlets to perform database operations.

 Java Server Pages (JSP)


JavaServer Pages (JSP) is a Java standard technology that enables you to write dynamic, data-
driven pages for your Java web applications. JSP is built on top of the Java Servlet
specification. 
he two technologies typically work together, especially in older Java web applications. From a
coding perspective, the most obvious difference between them is that with servlets you write
Java code and then embed client-side markup (like HTML) into that code, whereas with JSP
you start with the client-side script or markup, then embed JSP tags to connect your page to
the Java backend.

JSP is also closely related to JSF (JavaServer Faces), a Java specification for building MVC
(model-view-controller) web applications. JSP is a relatively simpler and older technology
than JSF, which is the standard for Java web frameworks like Eclipse Mojarra, MyFaces, and
PrimeFaces. While it is not uncommon to see JSP used as the frontend for older JSF
applications, Facelets is the preferred view technology for modern JSF implementations.

JSP is a server side technology that does all the processing at server. It is used for
creating dynamic web applications, using java as programming language.

Basically, any html file can be converted to JSP file by just changing the file extension
from “.html” to “.jsp”, it would run just fine. What differentiates JSP from HTML is the
ability to use java code inside HTML. In JSP, you can embed Java code in HTML using
JSP tags. for e.g. run the code below, every time you run this, it would display the
current time. That is what makes this code dynamic.

You might also like