Shared Flashcard Set

Details

Java EE 6 Web Component OCE
Java EE 6 Web Component OCE
100
Software
Professional
10/24/2012

Additional Software Flashcards

 


 

Cards

Term
Web Application and CGI
Definition
A Web Application is an application that is accessed over a network such as the Internet or an intranet.
CGI architecture is not like Java EE component-container model.
Term
Benefits of Java Servlet technology
Definition
For every HTTP request made, a new process is created for each call of the CGI script.
Each request to be handled by a Servlet is handled by a separate Java thread.
Term
Benefits of Java Servlet technology
Definition
Asynchronous support is Servlet 3.0's most significant enhancement --> Server side processing of Ajax
Term
Where to use Servlets?
Definition
To implement logic
To implement services
To generate binary content
As controllers
Term
@WebServlet
Definition
name =
urlPatterns = {}
initParams = { @InitParam(name, value) }
Term
Single-tier architecture
Definition
A tier is a logical group of application components
Centralized model
Presentation, Business, Logic and Data Access --> One monolithic mainframe
Term
Two-tier architecture
Definition
Fat clients taking to back end database. SQL queries sent and raw data returned. Presentation, Bussiness Logic and Data Model processing logic in client application
Term
Three tier architecture
Definition
Presentation, Business Logic and Data Access logic are handled in common server. Server interconnected with database. Zero client management
Term
Model-View-Controller (MVC)
Definition
MVC organizes an interactive application into three separate modules:
1. One for the application model with its data representation and business logic
2. The second for views that provide data representation and user input
3. And the third for a controller to dispatch requests and control flow
Term
MVC-1 and MVC-2
Definition
Model 1: JSP Centric Design
Model 2: Controller Servlet
Term
MVC - Model 1
Definition
Web browser --> Web-tier JSP pages
JSP pages --> Web-tier Java Beans
Java Beans --> Application model and Next view to display
Term
MVC - Model 2
Definition
Controller Servlet:
-Between the browser and the JSP Pages/Servlets
-Centralizes the logic for dispatching requests to the next view
-Handles view selection. Decouples JSP pages and Servlets from one another
Term
Introduction to Java EE Web Applications
Definition
Is a dynamic extension of a web or application server

-Presentation-oriented: Web application generates interactive web pages, dynamic content

-Service-oriented: Endpoint of a web service --> SOAP

Servlets --> Request/Response programming model
Term
Where to use Java Server Pages?
Definition
To create structured free-form textual data
Data presentation
To create structured textual content (HTML, XML, DHTML)
As templates
Used for content that is partially fixed, with some elements that are filled in dynamically at runtime
Term
JSP - MVC Architecture
Definition
Model --> Java Bean/Dispatched Entity
View --> JSP
Controller --> Servlet
Term
Code a Controller using a Servlet
Definition
HTTP Request --> Controller --> What application is requested?
-Form --> POST --> Hidden input
-Query parameter --> GET
Term
Controller mapping
Definition
A Servlet mapping is a deployment descriptor definition that compares request paths to a pattern (suffix, base URL) and dispatches matching requests to the corresponding Servlet
Term
Processing actions
Definition
Controller --> Invokes the corresponding application model method <-- based on request parameters
Term
Command Pattern
Definition
A controller can look up concrete Action subclasses by name and delegate requests to them
Term
Code a View using JSP
Definition
Screen flow --> Succession of views that a Web application user sees
Controller --> Controls screen flow
Term
MVC Flow
Definition
Controller:
1. Receives POST/GET Request
2. Creates an Action based on Request
3. Calls performAction()
4. performAction() --> Model business method
5. Calls screen flow manager
6. Screen flow manager returns the next view's name to the Controller
7. Forwards the request to the templating service
Term
Fundamentals of EL
Definition
-JSP expression language --> Allows accessing a Bean --> ${}
-Web container --> PageContext.findAttribute(String)
-If it is not found --> null
-If matches some implicit object --> Returns implicit object instead of the JavaBean
-EL uses "." operator
Term
Fundamentals of EL
Definition
EL unifies --> "." and "[]" operators
exprA.exprB = exprA["exprB"]
exprA evaluated into valueA
exprB evaluated into valueB
If either of them is null --> null
If "valueA":
-Map --> valueA.get(valueB)
-List --> valueB coerced to int
If coercion --> error --> returns error
If IndexOutOfBoundsException --> returns null
-JavaBean --> Coerce valueB to String <-- Must be a readable property of the JavaBean
Term
HTTP Protocol
Definition
-Based on a request/response paradigm
-Is connectionless and stateless
-To maintain state:
-Cookies (name/value pair)
-URL Rewriting --> By changing each link to contain some extra state information (risky)
Term
Internet Media Types (formerly MIME Content-Types)
Definition
-To provide open and extensible data typing and type negotation
-HTTP Server --> Information back --> Includes a MIME-like header to inform the client what kind of data follows the Header
Term
HTTP Request Formats
Definition
-GET
-POST
-HEAD
Term
HTTP GET Request
Definition

-Simplest request -URL which may have small amounts of

extra information --> ASCII characters

Term
HTTP POST Request
Definition
-Used to send significant amounts of information
-Data sent using multiple lines
Term
HTTP HEAD Request
Definition
-Used to find information about a page without looking at it (cached version)
Term
Servlet for HTTP based requests
Definition
-HTTP and HTTPS are very similar protocols with only the fact that HTTPS provides a layer of security (using SSL)
-They are both capable of passing a variety of data types without any understanding of the data being carried
-HTTPServlet method that corresponds to the HTTP Method
Term
Servlet method for HTTP GET requests
Definition
-protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
-Called by the server (via the service method) to allow a Servlet to handle a GET request
Term
Servlet method for HTTP POST requests
Definition
-protected void doPost(HttpServletRequest request, HttpServletResponse response) ServletException, IOException
-protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
-Called by the server (via the service method) to allow a Servlet to handle a POST request
Term
Get Method
Definition
-This method should be used for retrieving data ONLY
-Query string of form data during this method is simply appended to the URL as name-value pairs separated with '&'
-Query length is limited
-Users can see data in the browser's address bar
-Only ASCII (text) data can be sent to the server with GET method
Term
GET method triggers
Definition
-The web browser sends an HTTP GET request when the user types a URL in the browser's address bar
-The user clicks a link
-Retrieve a resource which was defined in src (image) or href (css, a) attributes
-A Form is submitted (Forms use method GET by DEFAULT)
Term
POST method purpose
Definition
This method should be used for posting new groups messages, submitting long data fields to a database (such as SQL insert of lengthy string), or sending binary files to a server
Term
POST method technical characteristics
Definition
-Sends information to the server such as form fields, large text bodies, and key-value pairs
-Hides data from users because it is not passed as a query string, but in the message body
-Sends UNLIMITED length data as part of its HTTP request body
-For sending ASCII (text) or binary data
-Disallows bookmars
Term
POST method triggers
Definition
-Web browser --> HTTP POST request:
-The user submits a form that specifies attribute method="POST"
-doPut for handling HTTP PUT requests
-protected doPut(HttpServlet request, HttpServlet response) throws ServletException, IOException
Term
POST method triggers
Definition
-PUT operation allows a client to place a file on the server and is similar to sending a file by FTP
-POST --> URI: Identifies the resource that will handle the enclosed entity
-PUT --> URI: Identifies the entity enclosed with the request
Term
DELETE request
Definition
-protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
-Allows a client to remove a document or Web page from the server
Term
HEAD request
Definition
-protected void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
-The client sends a HEAD request when it wants to see ONLY the HEADERS of a response
-Is a specialized form of the doGet method that returns only the headers produced by the doGet method
Term
OPTIONS request
Definition
-protected void doOptions(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
-Determines which HTTP methods the server supports and returns an appropriate header
Term
TRACE request
Definition
-protected void doTrace(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
-Generates a response containing all the instances of the headers sent in the TRACE request to the client, so they can be used in debugging
Term
HTTP Protocol Parameters
Definition
-HttpServletRequest --> The parameters are stored as a set of name-value pairs
-getParameter --> Returns the value of a request parameter as a String, or null if the parameter does not exist
-getParameterNames --> Returns an Enumeration of String objects containing the values of the parameter contained in this request. Otherwise returns an empty Enumeration
Term
HTTP Protocol Parameters
Definition
-getParameterValues --> Returns an array of String objects containing all the values of the given request parameter. Otherwise it returns null
-getParameterMap --> Returns an immutable java.util.Map containing parameter names as keys and parameter values as map values
-Keys --> String type
-Values --> Array of String
Term
HTTP Protocol Parameters
Definition
-Conditions before post FORM data
1. The request is an HTTP or HTTPS request
2. The HTTP method is POST
3. The content type is application/x-www-form-urlencoded
4. The servlet has made an initial call of any of the 'getParameter' family methods on the request object
Term
Headers
Definition
-getHeader:
-Returns the value of the specified request header as a String. Otherwise returns null
-Multiple headers with the first name --> Returns the first head in the request
-Header name is case insensitive
Term
Headers
Definition
-getHeaders:
-Returns all the values of the specified request header as en Enumeration of String objects. Otherwise returns an EMPTY Enumeration
Term
Headers
Definition
-getHeaderNames: Returns an enumeration of all the header names this request contains. If the requests has no headers, this method returns an empty enumeration.

Headers may contain String representations of int or Date data

-getIntHeader: Returns the value of the specified request header as an int. If the request does not have a header of the specified name, this method returns -1. If the header cannot be converted to an integer, this method throws a NumberFormatException

-getDateHeader: Returns the value of the specified request header as a long value that represents a Date object. Use this method with headers that contain dates, such as If-Modified-Since. The date is returned as the number of milliseconds since January 1, 1970 GMT. If the request did not have a header of the specified name, this method returns -1. If the header can't be converted to a date, the method throws an IllegalArgumentException
Term
Headers - HttpServletRequest Methods
Definition
-public java.lang.String getHeader(java.lang.String name);

-public java.util.Enumeration getHeaders(java.lang.String name);

-public java.util.Enumeration getHeaderNames();

-public int getIntHeader(java.lang.String name);

-public long getDateHeader(java.lang.String name);
Term
Cookies
Definition
-getCookies method to obtain an array of cookies that are present in the request. This method returns null if no cookies were sent

-The cookies are data sent from the client to the server on every request that the client makes

-The only information that the client sends back as part of a cookie is the cookie name and the cookie value

-Several cookies might have the same name but different path attributes
Term
Set Headers
Definition
A Servlet can set headers of an HTTP response

-setHeader. Sets a response header with the given name and value. OVERWRITES a previous one. Should use containsHeader to prevent overwriting

-addHeader. Adds a response header with the given name and value

-setIntHeader. Sets a response header with the given name and integer value. Overwrites a previous one. Should use containsHeader to avoid overwriting

-setDateHeader. Sets a response header with the given name and date-value (milliseconds). Overwrites a previous one. Should use containsHeader
Term
Set Headers
Definition
-addIntHeader. Adds a response header with the given name and integer value

-addDateHeader. Adds a response header with the given name and date-value (milliseconds)
Term
Content type
Definition
-setContentType(String) method --> Set the charset for the MIME body response

-Explicit specifications take precedence over implicit specifications

-Default charset: ISO-859-1

-MUST be called BEFORE getWriter and BEFORE commiting the response for the character encoding to be used
Term
Content type
Definition
There are two ways to define content type:

-ServletResponse.setContentType(String);
-HttpServletResponse.setHeader("Content-Type", "text/html");
Term
Acquire a text stream
Definition
-PrintWriter --> ServletResponse.getWriter() --> Uses the character encoding returned by getCharacterEncoding()

-ServletResponse.getOutputStream() --> For sending BINARY data to the client

May be called to write the body, NOT BOTH
Term
Acquire a binary stream
Definition

-ServletResponse.getOutputStream() --> An output stream for sending BINARY data to the client

-public interface ServletResponse {

     public ServletOutputStream getOutputStream() throws     IOException;

}

Term
Redirect an HTTP request to another URL
Definition
-HttpServletResponse.sendRedirect --> Set the appropriate headers and content body to redirect the client to a different URL

-If a partial URL is given and, for whatever reason, cannot be converted into a valid URL, then this method must throw an IllegalArgumentException

public interface HttpServletResponse extends javax.servlet.ServletResponse {
public void sendRedirect(java.lang.String location)
throws IOException;
}

-This method can accept relative URLs --> Must be converted (by the servlet container) into an absolute URL
Term
Add cookies to the response
Definition
-Servlet --> Browser --> HttpServletResponse.addCookie(Cookie)

-Browser:
-Expected to support up to 20 cookies
-300 total cookies
-4KB each
Term
Servlet life cycle
Definition
-Servlet --> Loaded, Instantiated, Initialized, Handles Requests and Taken Out of Service

-javax.servlet.Servlet interface --> init, service, destroy <-- GenericServlet/HttpServlet abstract classes
Term
Servlet life cycle - Servlet Class Loading and Instantiation
Definition
-The servlet container is responsible for loading and instantiating servlets
-Can occur when the container is started, or delayed until the container determines the servlet is needed to service a request
-When the servlet engine is started, needed servlet classes must be LOCATED --> locally or remotelly
-After loading the Servlet class, the container instantiates it for use
Term
Servlet life cycle - Servlet class initilization
Definition
-After the servlet object is instantiated, the container must initialize it before it can handle requests
-Can perform ONE-TIME activities --> configuration data, initialize costly resources...
-public interface Servlet {
public void init(Servletconfig config)
throws ServletException;
}
Term
Servlet life cycle - Request Handling
Definition
-After a servlet is properly initialized, the container may use it to handle client requests

-public interface Servlet {
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException;
}

-public abstract class HttpServlet extends javax.servlet.GenericServlet implements java.io.Serializable {
protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException;
}
Term
Servlet life cycle - End of Service
Definition
-The container is NOT REQUIRED to keep a servlet loaded for any particular period of time

-Servlet container --> Calls the destroy method --> Allow to release any resources and Save any persistence state

-public interface Servlet {
public void destroy()
}

-It must allow any threads that are currently running in the service method to complete execution
Term
HttpSession object
Definition
-Sessions are represented by an HttpSession object

-HttpServletRequest.getSession() --> Current session

-HttpServletRequest.getSession(boolean) --> If the request does not have a session, it creates one
Term
HttpSession
Definition
-A client joins a session when session tracking information has been returned to the server indicating that a session has been established. Until then, an HTTP session is considered to be new

-The one of three ways used to establish tracking of the session: Cookies, URL Rewriting or SSL

-Assume the container uses Cookies

-HttpSession.invalidate() --> Ends the session
Term
HttpSession Timeout
Definition
public interface javax.servlet.http.HttpSession {
public int getMaxInactiveInterval(); [sec]
public int setMaxInactiveInterval(int); [sec]
public void invalidate();
public boolean isNew();
}
Term
HttpSession Timeouts
Definition
30 <-- In minutes
Term
Listener notification
Definition
-Object is added to session

-javax.servlet.http.HttpSessionAttributeListener
-java.servlet.http.HttpSessionBindingEvent

-public void attributeAdded(HttpSessionBindingEvent)
-public void attributeRemoved(HttpSessionBindingEvent)
-public void attributeReplaced(HttpSessionBindingEvent)
Term
Object notification
Definition
-javax.servlet.http.HttpSessionActivationListener -javax.servlet.http.HttpSessionEvent -public void sessionWillPassivate(HttpSessionEvent) -public void sessionDidActivate(HttpSessionEvent)
Term
Session management mechanisms
Definition
-Cookies:
-Most used
-REQUIRED to be supported by all servlet
containers
-JSESSIONID (uppercase!!!)

-SSL Sessions --> Has a built in mechanism allowing multiple requests from a client to be unambiguously identified

-URL Rewriting
-When a client will not accept cookies
-The session ID must be encoded as a path
parameter in the URL string
-Parameter name --> jsessionid (lowercase!!!)
Term
Session management mechanisms
Definition
-encodeURL(String) --> Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged

-encodeRedirectURL(String) --> Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged
Term
ServletContext initialization parameters
Definition
-getInitParameter --> Returns a String containing the value of the named CONTEXT-WIDE initialization parameter, or null if the parameter does not exist.

-getInitParameterNames --> Returns the names of the context's initialization parameters as an Enumeration of String objects, or an EMPTY Enumeration if the context has NO initialization parameters
Term
ServletContext initialization parameters
Definition
Term
Servlet 3.0 initialization
Definition
@WebServlet(name="mytest", urlPatterns={"/myurl"}, initParams={@InitParam(name="product", value="Java EE 6 JSP and Servlet OCE Training Lab")}) public class InitExampleServlet extends javax.servlet.http.HttpServlet{} product Java EE 6 JSP and Servlet OCE Training Lab
Term
Request Attributes
Definition
-Attributes are objects associated with a request

-May be set by the container or may be set by a Servlet --> RequestDispatcher --> Another Servlet

-getAttribute --> Returns the value of the named attribute as an Object, or null if no attribute of the given name exits <-- setAttribute(String, Object)

-getAttributeNames --> Returns an Enumeration containing the names of the attributes available to this request. Return an EMPTY Enumeration if request has no attributes available to it
Term
Request Attributes
Definition
-setAttribute --> Stores an attribute in this request. Attributes are reset between requests. Is often used in conjunction with RequestDispatcher.

-Attribute names should follow the same conventions as package names

-setAttribute("attributeName", null) --> removeAttribute("attributeName")
Term
Request Attributes
Definition
package javax.servlet;

public interface ServletRequest {
public Object getAttribute(String);
public Enumeration getAttributeNames();
public void setAttribute(String, Object);
public void removeAttribute(String);
}
Term
Session Attributes
Definition
A Servlet can bind an Object Attribute into an HttpSession

-getAttribute --> Returns the object bound with the specified name in this session, or null if no object is bound under the name

-getAttributeNames --> Returns an Enumeration of String objects containing the names of all the objects bound to this Session

-setAttribute --> Binds an Object to this Session, using the name specified. If an Object of the same name is already bound to the Session, the Object is replaced
Term
Session Attributes
Definition
-setAttribute

-After this method executes --> If the Object implements HttpSessionBindingListener <-- HttpSessionBindingListener.valueBound

-The container then notifies any HttpSessionAttributeListeners
Term
Session Attributes
Definition
-removeAttribute --> Removes the Object bound with the specified name <-- Otherwise does nothing

-After execution --> If Object implements HttpSessionBindingListener <-- HttpSessionBindingListener.valueUnbound

-The valueBound method must be called BEFORE the Object is available via --> getAttribute

-The valueUnbound method must be called AFTER the object is no longer available via --> getAttribute
Term
Context Attributes
Definition
-A Servlet can bind an Object Attribute into the Context by name

-This Object will be available to ANY Servlet that is part of the same Web application
Term
Context Attributes
Definition
-setAttribute --> Binds an object to a given attribute name in this Servlet context --> If the name already exists, it will be REPLACED

-getAttribute --> Returns the Servlet container attribute with the given name, or null if there is no attribute by that name

-getAttributeNames --> Returns an Enumeration containing the attribute names available within this Servlet context

-removeAttribute --> Removes the attribute with the given name form the Servlet context
Term
Request Processing Model
Definition
-The Container, when receiving an incoming Request, identifies the target Web resource according to the rules of mappings.
Term
Request processing model
Definition
-The order the container uses in building the chain of filters: 1.First, the matching filter mappings in the same order that these elements appear in the Deployment Descriptor The last Filter in this chain is the Filter that invokes the first filter in the matching chain, or invokes the target Web resource if there are none.
Term
Request processing model
Definition
2. Next, the matching filter mappings in the same order that these elements appear in the Deployment Descriptor The last Filter in this chain corresponds to the last matching Filter and is the Filter that invokes the target Web resource
Term
Writing and configuring a Filter
Definition
-Filters are Java components
-Is a reusable piece of code that can TRANSFORM the content of HTTP requests, responses, and header information
-Do not generally create a response or respond to a request as Servlets do
Term
Writing and configuring a Filter
Definition
The main tasks that a Filter can perform are as follows:

-Query the request and act accordingly
-Block the request and response pair from passing any further
-Modify the request headers and data
-Modify the response headers and data
-Interact with external resources

Interfaces:
-javax.servlet.Filter
-javax.servlet.FilterChain
-javax.servlet.FilterConfig
Term
Writing and configuring a Filter
Definition
doFilter <-- Most importan method
Which is passed request, response, and filter chain objects.

This method can perform the following actions:
-Customize the request object if it wishes to modify request headers or data
-Customize the response object if it wishes to modify response headers or data
-Examine response headers after it has invoked the next filter in the chain
-Throw an exception to indicate an error in processing
Term
Writing and configuring a Filter
Definition
-Invoke the next Entity in the Filter Chain
-If it is the last filter in the chain that ends with the target Web component or static resource, the next Entity is the resource at the end of the chain; otherwise, it is the next Filter that was configured in the WAR
-It invokes the next Entity by calling the doFilter method on the chain object
-Alternatively, it can choose to block the request by not making the call to invoke the next Entity
Term
Wrapping Request and Response Objects
Definition
-A Filter can wrap up the Request or Response Objects in a custom wrapper

-Such custom wrappers then modify the information provided to the Servlet via a Request Object or process information generated by the Servlet via the Response Object

-javax.servlet.ServletRequestWrapper
-javax.servlet.ServletResponseWrapper
-javax.servlet.http.HttpServletRequestWrapper
-javax.servlet.http.HttpServletResponseWrapper
Term
Web Container Life Event
Definition
-HTTP Session Listeners are used to manage state or resources associated with a series of requests made into a Web Application from the SAME client or user

-Servlet Request Listeners are used to manage state across the lifecycle of Servlet Requests
Term
Web Container Life Event
Definition
-All ServletContextListeners are notified of context initialization before any filter or Servlet in the Web Application is initialized

-All Servlet and Filters have been destroyed before any ServletContextListeners are notified of context destruction
Term
Web Container Life Cycle Event
Definition
package javax.servlet;
public interface ServletContextListener extends java.util.EventListener {
public void contextDestroyed(ServletContextEvent sce);
public void contextInitialized(ServletContextEvent sce);
}

public class ServletContextEvent extends java.util.EventObject {
public ServletContext getServletContext();
}
Term
Web Container Life Event
Definition
package javax.servlet;
public interface ServletContextAttributeListener extends java.util.EventListener {
public void attributeAdded(ServletContextAttributeEvent);
public void attributeRemoved(ServletContextAttributeEvent);
public void attributeReplaced(ServletContextAttributeEvent);
}
Term
Web Container Life Event
Definition
-Implementations of the following interface are notified of changes to the list of active sessions in a Web Application

-To receive notification events, the implementation class must be configured in the deployment descriptor for the web application

package javax.servlet.http;
public interface HttpSessionListener extends java.util.EventListener {
public void sessionCreated(HttpSessionEvent);
public void sessionDestroyed(HttpSessionEvent);
}
Term
Web Container Life Event
Servlet Request Events and Listeners
Definition
-To be notified of requests coming in and out of scope in a web component

-Request --> Coming into scope <-- About to enter the FIRST Servlet or Filter

-Request --> Out of scope <-- When exits the LAST Servlet or the FIRST Filter in the chain
Term
Web Container Life Event
Servlet Request Events and Listeners
Definition
package javax.servlet;
public interface ServletRequestListener {
requestInitialized(ServletRequestEvent sre);
requestDestroyed(ServletRequestEvent sre);
}
Term
Web Container Life Event
Servlet Request Events and Listeners
Definition
ServletRequestAttributeListener <-- Interested in being notified of request attribute changes

package javax.servlet.*;

public interface ServletRequestAttributeListener {
public void attributeAdded(ServletRequestAttributeEvent srae);
public void attributeRemoved(ServletRequestAttributeEvent srae);
public void attributeReplaced(ServletRequestAttributeEvent srae);
}
Term
Web Container Life Event
RequestDispatcher
Definition
-Defines an Object that receives Requests from the Client and sends them to any Resource (HTML, JSP, Servlet)

-Servlet Container --> RequestDispatcher --> Wrapper around a Server Resource

-ServletContext.getRequestDispatcher(String path) --> Takes a String argument describing a Path within the Scope of the ServletContext

-ServletContext.getNamedDispatcher(String name) --> Takes a String argument indicating the NAME of a Servlet known to the ServletContext

-SerlvetRequest.getRequestDispatcher(String path) --> To allow RequestDispatcher Objects to be obtained using relative Paths that are relative to the Path of the current Request
Term
RequestDispatcher
Definition
RequestDispatcher rd = request.getRequestDispatcher("AResource.jsp");
if (rd != null) {
rd.forward(request, response);
}

-Forward should be called before the response has been commited to the client (flushed) <-- IllegalStateException

RequestDispatcher rd = getServletContext().getRequestDispatcher("AResource.jsp");
if (rd != null) {
rd.include(request, response);
}

-Includes the content of a resource in the response
-Programmatic server-side includes
-The ServletResponse object has its path elements and parameters remain unchanged from the caller's
Supporting users have an ad free experience!