WAS v8.5 > WebSphere applications > Web applications > Learn about web applications > Web applications

Servlets

Servlets are Java programs that use the Java Servlet Application Programming Interface (API). You must package servlets in a WAR file or web module for deployment to the application server. Servlets run on a Java-enabled web server and extend the capabilities of a web server, similar to the way applets run on a browser and extend the capabilities of a browser.

Servlets can support dynamic web page content, provide database access, serve multiple clients at one time, and filter data.

In the application server, discussions of servlets focus on HTTP servlets, which serve Web-based clients.

We can define servlets as welcome files. Non-servlet resources are served only when the fileServingEnabled attribute is set to true in the IBM extensions XMI file, ibm-web-ext.xmi, located in each Web module WEB-INF directory or using an assembly tool to set the property in the source .war file. Serving welcome files is connected to serving static content. Therefore the fileServingEnabled attribute is set in the web module.

For IBM extension and binding files, the .xmi or .xml file name extension is different depending on whether you are using a pre-Java EE 5 application or module or a Java EE 5 or later application or module. An IBM extension or binding file is named ibm-*-ext.xmi or ibm-*-bnd.xmi where * is the type of extension or binding file such as app, application, ejb-jar, or web. The following conditions apply:

However, a Java EE 5 or later module can exist within an application that includes pre-Java EE 5 files and uses the .xmi file name extension.

The ibm-webservices-ext.xmi, ibm-webservices-bnd.xmi, ibm-webservicesclient-bnd.xmi, ibm-webservicesclient-ext.xmi, and ibm-portlet-ext.xmi files continue to use the .xmi file extensions. sptcfg


Context parameters

A servlet context defines the server view of the web application within which the servlet is running. The context also supports a servlet to access its available resourcest. Using the servlet context, a servlet can log events, obtain URL references to resources, and set and store attributes for other servlets in the context to use. These properties declare the parameters for the context of a web application. The properties convey setup information, such as the email address for the webmaster or the name of a system with critical data.


Servlet mappings

A servlet mapping is a correspondence between a client request and a servlet. Web containers use URL paths to map client requests to servlets, and follow the URL path-mapping rules as specified in the Java Servlet specification. The container uses the Uniform Resource Identifier (URI) from the request, minus the context path, as the path to map to a servlet. The container chooses the longest matching available context path from the list of web applications that it hosts.


Related


Develop servlets with WAS extensions


Reference:

Web applications: Resources for learning


+

Search Tips   |   Advanced Search