Deployment Structure of a Web-Server
Though
it varies a lot from Server to Server, some of the components are
very common.
WEB-INF
folder is hidden from web-users and is visible only to the
programmer/server. It contains the following sub-folders/files:
classes/
: Folder containing compiled classes. classes
may have sub-directories that correspond to the package structure,
the same as any other directory in a class-path.
lib/
: Similar to classes folder but contains .jar files. Any lib placed
here is made automatically available to web server.
web.xml
: This file has several mappings for servlet options.
tlds/
: Contains Tag-Library-Descriptors.
jsp/
: Conatins generated Servlet code. (Only used in JRun).
sessions/
: Contains serialized versions of sessions (Only used in JRun).
Elements of web.xml
Filters
Filters
are used in web application to pre-process request and post-process
response before/after passing control to the servlet.
This
is helpful when its not possible to change the servelt itself but as
expected, it degrades the performance of the entire system. However,
it can be used for:
Filters
can be used by doing the following:
<filter>
<filter-name>myFilter</filter-name>
<filter-class>examples.myFilterClass</filter-class>
<init-param>
<param-name>myInitParam</param-name>
<param-value>myInitParamValue</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>myFilter</filter-name>
<url-pattern>/myPattern/*</url-pattern>
</filter-mapping>
Listeners
These
are event listener classes which can be added for listening to events
like:
Servlet-Context
Events:
servlet
context - creation and destroying.
attributes
- add, remove and replacement in servlet-context.
HTTP-Session
Events:
Listeners
are implemented by doing the following:
<listener>
<listener-class>myApp.MyContextListenerClass</listener-class>
</listener>
Java
checks the type of listener-interface implemented by each class and
calls the appropriate listener for different events.
More
than one listener can be registered for one event.
|