DevPortal

How do I work with Servlets on Pramati Server?


Table of Contents


How do I work with Servlets on Pramati Server?

To run a servlet, package it in a .war file along with the helper classes, the Java classes used by the servlet. Deploy the .war file and access the servlet from the browser.

How do I run Servlets without packaging?

Servlets can be run on the Server without packaging them into .war or .ear files. To do this, store the servlet class in the document root of the virtual host in the Server.

Example: <install_dir>/server/nodes/<node_name>/archives/public_html/web-inf/classes.

If the servlet has a package, then the same needs to be created under web-inf/classes directory.

Example: <install_dir>/server/nodes/<node_name>/archives/public_html/web-inf/classes/com/pramati/abc.class.

Note: The location of the document root of the Server is specified in the web-config xml.

The Server classpath must be updated to contain all the helper classes that the servlet will access. The servlet helper classes are located at <install_dir>/server/nodes/<node_name>/archives/public_html/servlet.

How do I add Servlets to a running Server?

Servlets can be dynamically added to the running Server. When a request for a Servlet is made, the Server looks for the servlet in the document root's web-inf/classes directory of Server.

If the servlet is found, the Server returns the request, else it throws a file not found error.

How do I access Servlets?

To access a servlet running on Server, specify http://<host-name>:<port>/<servlet_name>, as http://localhost:8181/contextroot/<servlet_path>/<servlet_name>.

Here, host-name is the name or IP of the machine on which Server is running, port is the port on which the Web container handles HTTP requests, servlet_path is the fully qualified path for the servlet class, and servlet_name is the name of the Servlet that is being accessed.

Example: If sample is the context root and package1.package2.Test is the fully qualified path for the Servlet class, the link is: http://localhost:8181/sample/package1/package2/Test.


© Pramati Technologies 2007 Runs on Pramati Server | Feedback | Legal