Make delicious recipes!

Deployment Structure of a Web-Server

Though it varies a lot from Server to Server, some of the components are very common.

  1. WEB-INF folder is hidden from web-users and is visible only to the programmer/server. It contains the following sub-folders/files:

    1. 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.

    2. lib/ : Similar to classes folder but contains .jar files. Any lib placed here is made automatically available to web server.

    3. web.xml : This file has several mappings for servlet options.

    4. tlds/ : Contains Tag-Library-Descriptors.

    5. jsp/ : Conatins generated Servlet code. (Only used in JRun).

    6. sessions/ : Contains serialized versions of sessions (Only used in JRun).

Elements of web.xml


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:

  • Logging - request and response objects.

  • Encryption

  • Compression

  • Implementation of some user-written security functionality.

Filters can be used by doing the following:

  • Have a class that implements javax.servlet.Filter

  • Create an instance of the above filter in web.xml and map it to a URL-pattern.

  • Example:





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:

    • session activation and deactivation.

    • attributes - add, remove and replacement in session.

Listeners are implemented by doing the following:

  • Create a class that implements event-specific listener interface.

  • Add listener tag to web.xml as follows:




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.

Like us on Facebook to remain in touch
with the latest in technology and tutorials!

Got a thought to share or found a
bug in the code?
We'd love to hear from you:

Email: (Your email is not shared with anybody)

Facebook comments:

Site Owner: Sachin Goyal