Self Study Memo

Important Point
Develop Custom Tag Library
JSTL&EL
Web Security

  1. Filter

You need to understand these points when using filters:
There is one filter per <filter> entry in the web.xml file, per virtual machine.
A servlet container is free to run multiple threads on the same filter object to service
multiple requests simultaneously.
As of Servlet spec 2.4, filters can now be configured to be invoked on any combination
of the following:
• As a result of calling RequestDispatcher.forward()
• As a result of calling RequestDispatcher.include()
• On error pages

<filter-mapping>
<filter-name>AccessLog</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
  1. Understanding the WEB-INF directory

Every web application must have a WEB-INF directory directly under its root directory.
Although it is physically located inside the document root directory, it is not considered
a part of the document root; i.e., files in the WEB-INF directory are not served
to the clients. This directory contains three things:
• classes directory—The servlet class files and the class files needed to support the
servlets or JSP pages of this web application go in this directory if they have not
been included in a JAR file. The class files should be organized according to
their packages. At runtime, the servlet container adds this directory to the classpath
for this web application.
• lib directory—All the JAR files used by the web application, including the thirdparty
JAR files, go in this directory. For example, if a servlet uses JDBC to connect
to a database, the JDBC driver JAR file should go here. We can also package
the servlet classes in a JAR file and keep that file in this directory. At runtime,
the servlet container adds all the JAR files from this directory to the classpath for
this web application.
• web.xml file (also known as the deployment descriptor)—This file is the heart of
a web application, and every web application must have it. It contains the information
needed by the servlet container in order to run the web application,
such as servlet declarations and mappings, properties, authorization and security
constraints, and so forth.

  1. THE DEPLOYMENT DESCRIPTOR: AN OVERVIEW
Web Application Properties Short Description
Servlet Declarations Used to specify servlet properties.
Servlet Mappings Used to specify URL to servlet mapping.
Application Lifecycle Listener classes Used to specify listener classes for HttpSession Events and ServletContextAttributeEvent.
ServletContext Init Parameters Used to specify initialization parameters for the web application.
Filter Definitions and Filter Mappings Used to specify the filter.
Session Configuration Used to specify session timeout.
Security Constraints Used to specify security requirements of the web application.
Tag libraries Used to specify the tag libraries required by JSP pages.
Welcome File list Used to specify the welcome files for the web application.
MIME Type Mappings Used to specify MIME types for common file extensions.
JNDI names Used to specify JNDI names of the EJBs.
  1. Tag Library Descriptor

[[code type="xml"]]
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC
"-Sun Microsystems, Inc.DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd" >
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>2.0</jsp-version>
<short-name>test</short-name>
<uri>http://www.manning.com/sampleLib</uri>
<tag>
<name>greet</name>
<tag-class>sampleLib.GreetTag</tag-class>
<body-content>empty</body-content>
<description>Prints Hello and the user name</description>
Listing 16.1 sampleLib.tld: A sample tag library descriptor
Licensed to Tricia Fu <moc.liamg|uf.aicirt#moc.liamg|uf.aicirt>
UNDERSTANDING THE TAG LIBRARY DESCRIPTOR 311
<attribute>
<name>user</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
[[code]]

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License