 |
GET is the most common
HTTP method. It is used to request a resource
from the server. |
|
| The Structure and Deployment
of Modern Servlet Web Applications |
 |
Similar to JAR, which
is used to package Java class libraries,
WAR (Web Application Archive) is used to
package web components in a J2EE (Java
2 Enterprise Edition) application. |
|
| The Servlet Container Model |
 |
The getServletContext()
method of the GenericServlet class returns
a ServletContext object that contains information
regarding the server environment in which
the servlet is running. |
|
| Designing and Developing Servlets
to Handle Server-side Exceptions |
 |
The sendError() method
of the HttpServletResponse interface returns
an error message to the client according
to the specified status code. Every HTTP
response returned from the server begins
with a status code. For example, the status
code range 2xx (200's) indicates Success. |
|
| Designing and Developing
Servlets using Session Management |
 |
State management is the
ability to maintain a client's current
state by passing client-specific information
between the client and the server. In contrast,
session management provides an association
between the client and the server, which
allows server to uniquely identify each
client. This association persists across
the requests for a specified period of
time. Allowing clients to select the background
color of their HTML pages is an example
of state management. With state management,
the client identity can't be maintained.
For example, 2 clients select red as their
background color. With only state management,
the server can determine the preferred
background color for each of these clients
but it cannot distinguish one client from
the other. The solution to this is the
session management, which is the superset
of state management and maintains both
state as well as identity. |
|
| Designing and Developing
Secure Web Applications |
 |
Authentication vs Authorization
- Designing and Developing Secure Web Applications.
Authentication: Verifying the user, e.g.
asking for ID/password at the time of login.
There are different types of authentication
- BASIC, DIGEST, FORM, and CLIENT-CERT.
Authorization: An authenticated user is
allowed to access a particular resource.
A user may be authenticated but still not
have access to all the resources. |
|
| Designing and Developing Thread-safe Servlets |
 |
The simplest way to ensure thread safety in a Java servlet is
to implement the SingleThreadModel interface, by doing which
the web server guarantees that no more than one thread can execute
service(), doGet(), doPost() methods at a time for a particular
servlet instance. In case SingleThreadModel interface is implemented,
the service(), doPost(), doGet() methods cannot be executed concurrently. |
|
| The JavaServer
Pages (JSP) Technology Model |
 |
Scripting elements are
used to include scripting code (normally
Java code) within the JSP. The three types
of scripting elements are:
 |
Declarations (e.g., <%!
int i=4; %>)
|
 |
Scriptlets (e.g.,
<% for (int i=0; i<10; i++) { out.println("The counter
is:" + i); } %>) |
 |
Expressions (e.g., <%
=myBean.getNumber() %>) |
|
|
| Designing and Developing Reusable Web Components |
 |
The JSP directives serve
as messages to the JSP container from the
JSP. Directives are characterized by '@'
and are used to set global values such
as class declaration, methods to be implemented,
output content type, etc. They do not produce
any output to the client. The 3 directives
are as follows:
 |
The page directive
(e.g., <%@ page import="java.net.*" buffer="10k" %>) |
 |
The include
directive (e.g., <%@ include
file="myFile.html" %>) |
 |
The taglib directive
(e.g., <%@ taglib url="http://www.whizlabs.com/mytags" prefix="tt" %>) |
|
|
| Designing and Developing
JSP Pages using JavaBeans Components |
 |
Actions are specific tags that affect the runtime behavior of
the JSP and the response sent back to the client. The standard
action types are:
 |
<jsp:useBean> (e.g., <jsp:useBean
id="myBean scope="application" class="mypackage.MyBean" />) <jsp:setProperty> (e.g., < jsp:setProperty name="myBean" property="word" />) <jsp:getProperty> (e.g., <jsp:getProperty name="myBean" property="word" />) <jsp:param> (e.g., <jsp:param name="paramname" value="paramvalue" />) <jsp:include> (e.g., <jsp:include page="filename" />) <jsp:forward> (e.g., <jsp:forward page="url" />) <jsp:plugin> (e.g., <jsp:plugin type="applet code="mypackage.MyApplet" codebase="/classes" height="100" width="100"> ) |
|
 |
The Java objects within a JSP page
can be associated with a scope attribute
defining where there is a reference to
the object and when that reference is
removed. Following are the various scopes
that can be associated with a newly created
object. The object inside application
scope is the most visible or accessible
followed by session, request, and then
page inside which an object is least
visible.
 |
Application - An
object inside an application scope
is accessible from all the pages
that belong to the particular application. |
 |
Session - An object
inside session scope is visible from
all the pages belonging to the session
in which it was created. |
 |
Request -
An object inside a request scope
is accessible from all the pages
processing the request where the
object was created. |
 |
Page - An object
inside a page scope is accessible
only from the page in which it was
created. |
|
|
| Designing and Developing
JSP Pages Using Custom Tags |
 |
JSP tags can cooperate with each other
by sharing objects. The object created
by the enclosing tag of a group of nested
tags is available to all the inner tags.
Here is an example: <tt:outerTag> <tt:innerTag /> </tt:outerTag> |
|
| Designing and Developing a Custom Tag Library |
 |
The JSP custom tags are extensions to the JSP language. These
are usually distributed in the form of a tag library, which defines
a set of related custom tags and contains the objects that implement
the tags. Some examples of tasks that can be performed by custom
tags include operations on implicit objects, form processing,
accessing databases, etc. |
|
 |
The most popular JSP Architecture
is a server side implementation of the
popular MVC (Model View Controller) design
pattern. Here the Servlet represents
the Controller, JSP the view, and JavaBean
maps to the model. The servlet takes
the request from the client (browser),
instantiates/creates the JavaBean, and
forwards the request to the JSP. Finally,
JSP, which represents the view, sends
back the response to the client. |
|
| To avail the benefits of the Licensed Version, please click
here. |
|