Noor Java
Noor Java
Noor Java
based applications, without the performance limitations of CGI programs. Servlets have
access to the entire family of Java APIs, including the JDBC API to access enterprise
databases. This tutorial will teach you how to use Java Servlets to develop your web
based applications in simple and easy steps.
Applications of Servlet
• Read the explicit data sent by the clients (browsers). This includes an
HTML form on a Web page or it could also come from an applet or a custom
HTTP client program.
• Read the implicit HTTP request data sent by the clients (browsers). This
includes cookies, media types and compression schemes the browser
understands, and so forth.
• Process the data and generate the results. This process may require talking
to a database, executing an RMI or CORBA call, invoking a Web service, or
computing the response directly.
• Send the explicit data (i.e., the document) to the clients (browsers). This
document can be sent in a variety of formats, including text (HTML or XML),
binary (GIF images), Excel, etc.
• Send the implicit HTTP response to the clients (browsers). This includes
telling the browsers or other clients what type of document is being
returned (e.g., HTML), setting cookies and caching parameters, and other
such tasks.
Audience
This tutorial is designed for Java programmers with a need to understand the Java
Servlets framework and its APIs. After completing this tutorial you will find yourself at
a moderate level of expertise in using Java Servlets from where you can take yourself to
next levels.
Prerequisites
We assume you have good understanding of the Java programming language. It will be
great if you have a basic understanding of web application and how internet works.
XML (Extensible Markup Language) is a very popular simple text-based language that can be
used as a mode of communication between different applications. It is considered as a
standard means to transport and store data. JAVA provides excellent support and a rich set of
libraries to parse, modify or inquire XML documents. This tutorial will teach you basic XML
concepts and the usage of various types of Java based XML parsers in a simple and intuitive
way.
XML is a simple text-based language which was designed to store and transport data
in plain text format. It stands for Extensible Markup Language. Following are some of
the salient features of XML.
• XML is a markup language.
• XML is a tag based language like HTML.
• XML tags are not predefined like HTML.
• You can define your own tags which is why it is called extensible language.
• XML tags are designed to be self-descriptive.
• XML is W3C Recommendation for data storage and data transfer.
Advantages
Following are the advantages that XML provides −
• Technology agnostic − Being plain text, XML is technology independent. It
can be used by any technology for data storage and data transfer purpose.
• Human readable − XML uses simple text format. It is human readable and
understandable.
• Extensible − In XML, custom tags can be created and used very easily.
• Allow Validation − Using XSD, DTD and XML structures can be validated
easily.
, the View used to display the data and the Controller contains the servlets
. Due to this separation the user requests are processed as follows:
1. A client (browser) sends a request to the controller on the server side, for a page.
2. The controller then calls the model. It gathers the requested data.
3. Then the controller transfers the data retrieved to the view layer.
4. Now the result is sent back to the browser (client) by the view.
JSP technology is used to create web application just like Servlet technology. It can be
thought of as an extension to Servlet because it provides more functionality than servlet
such as expression language, JSTL, etc.
A JSP page consists of HTML tags and JSP tags. The JSP pages are easier to maintain than
Servlet because we can separate designing and development. It provides some additional
features such as Expression Language, Custom Tags, etc.
1) Extension to Servlet
JSP technology is the extension to Servlet technology. We can use all the features of the
Servlet in JSP. In addition to, we can use implicit objects, predefined tags, expression
language and Custom tags in JSP, that makes JSP development easy.
2) Easy to maintain
JSP can be easily managed because we can easily separate our business logic with
presentation logic. In Servlet technology, we mix our business logic with the presentation
logic.
If JSP page is modified, we don't need to recompile and redeploy the project. The Servlet
code needs to be updated and recompiled if we have to change the look and feel of the
application.
In JSP, we can use many tags such as action tags, JSTL, custom tags, etc. that reduces the
code. Moreover, we can use EL, implicit objects, etc.
Note: jspInit(), _jspService() and jspDestroy() are the life cycle methods of JSP.