public interface Control
A control is a small Java program that runs within the MVC Control framework of a J2EE Web server. Controls receive and respond to requests from Web clients, usually across HTTP, the HyperText Transfer Protocol.
This interface defines methods to initialize a control, to service requests, and to remove a control from the server. These are known as life-cycle methods and are called in the following sequence:
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Called by the MVC Control container to indicate that the control is being taken out of service.
|
String |
doLogic(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Called by the MVC Control container to allow the control to respond to a request.
|
void |
init()
Called by the MVC Control container to indicate that the control is being placed into service.
|
void init() throws javax.servlet.ServletException
javax.servlet.ServletException
- if an exception has occurred that interferes with the control's normal operationString doLogic(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
This method is only called after the control's init() method has completed successfully.
Controls typically run inside multithreaded servlet containers that can handle multiple requests concurrently. Developers must be aware to synchronize access to any shared resources such as files, network connections, and as well as the control's class and instance variables.
The method returns a String to indicate how to proceed after the method completes. A
null
value means continue along the filter chain to the next element. A
response of "R:resource-url" indicates that a client-side redirection to the resource
URL should be performed. A response of "D:resource-url" indicates that a server-side
request dispatcher forward to the resource URL should be performed. For any other return
value the request is not passed to the next element in the filter chain.
request
- the HttpServletRequest
object that contains the client's requestresponse
- the HttpServletResponse
object that contains the control's responsejavax.servlet.ServletException
- if an exception has occurred that interferes with the control's normal operationIOException
- if an input or output exception occursControlFilter
void destroy()