Module JavaServlet

module JavaServlet: sig .. end
Support for Java servlets.

In order to compile a module as either a servlet or a servlet listener, it is necessary to compile the module with the -servlet k command-line switch, where k designates the kind of servlet or servlet listener. A servlet class will be generated, with the name pack.MImpl (where M is the name of the compiled module) where pack can be set using the -java-package pack command-line switch.

When compiling with the -servlet k command-line switch, the module has to be compatible with one of the module types of the JavaServlet module, the exact module type depending on the value of k. The following table gives the module types for the different applet kinds.

The various kinds of servlet.
parameter to -servlet module type
generic Generic
http HTTP
context-listener ServletContextListener
context-attribute-listener ServletContextAttributeListener
session-listener HTTPSessionListener
session-activation-listener HTTPSessionActivationListener
session-attribute-listener HTTPSessionAttributeListener
session-binding-listener HTTPSessionBindingListener
session-id-listener HTTPSessionIdListener



Generic servlets

 
type generic = javax'servlet'GenericServlet java_instance
Shorthand for the type of generic servlets.
 
type request = javax'servlet'ServletRequest java_instance
Shorthand for the type of requests to generic servlets.
 
type response = javax'servlet'ServletResponse java_instance
Shorthand for the type of responses to generic servlets.
 
module type Generic = sig .. end
The module type for servlets compiled with -servlet generic.
 
module Default_Generic: sig .. end
Default implementation for generic servlets.
 

HTTP servlets

 
type http = javax'servlet'http'HttpServlet java_instance
Shorthand for the type of HTTP servlets.
 
type http_request = javax'servlet'http'HttpServletRequest java_instance
Shorthand for the type of requests to HTTP servlets.
 
type http_response = javax'servlet'http'HttpServletResponse java_instance
Shorthand for the type of responses to HTTP servlets.
 
module type HTTP = sig .. end
The module type for servlets compiled with -servlet http.
 
val options : http_response ->
[ `DELETE | `GET | `HEAD | `OPTIONS | `POST | `PUT | `TRACE ] list -> unit
options resp l is an implementation of do_options _ _ _ resp where l is the list of methods supported by the servlet.
 
module Default_HTTP: sig .. end
Default implementation for HTTP servlets.
 

Listeners

 
type servlet_context_event = javax'servlet'ServletContextEvent java_instance
Shorthand for the type of context events.
 
type servlet_context_attribute_event = javax'servlet'ServletContextAttributeEvent java_instance
Shorthand for the type of context attribute events.
 
type http_session_event = javax'servlet'http'HttpSessionEvent java_instance
Shorthand for the type of session events.
 
type http_session_binding_event = javax'servlet'http'HttpSessionBindingEvent java_instance
Shorthand for the type of session binding events.
 
module type ServletContextListener = sig .. end
The module type for listeners compiled with -servlet context-listener.
 
module type ServletContextAttributeListener = sig .. end
The module type for listeners compiled with -servlet context-attribute-listener.
 
module type HTTPSessionListener = sig .. end
The module type for listeners compiled with -servlet session-listener.
 
module type HTTPSessionActivationListener = sig .. end
The module type for listeners compiled with -servlet session-activation-listener.
 
module type HTTPSessionAttributeListener = sig .. end
The module type for listeners compiled with -servlet session-attribute-listener.
 
module type HTTPSessionBindingListener = sig .. end
The module type for listeners compiled with -servlet session-binding-listener.
 
module type HTTPSessionIdListener = sig .. end
The module type for listeners compiled with -servlet session-id-listener.