Package io.github.jirkasa.servletrouter
Class Controller<Request extends javax.servlet.ServletRequest,Response extends javax.servlet.ServletResponse>
java.lang.Object
io.github.jirkasa.servletrouter.Controller<Request,Response>
- Type Parameters:
Request
- Type of ServletRequest.Response
- Type of ServletResponse.
- Direct Known Subclasses:
ErrorController
,HttpController
public abstract class Controller<Request extends javax.servlet.ServletRequest,Response extends javax.servlet.ServletResponse>
extends Object
Represents component that is used to handle incoming requests for specific path (usually) in application.
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
Controller
public Controller()
-
-
Method Details
-
getPathParam
Returns path parameter.- Parameters:
paramName
- Name of path parameter.- Returns:
- Value of path parameter or null.
-
handle
Handles request.- Parameters:
request
- Request to be handled.response
- Response to be handled.- Returns:
- Determines whether handlers chain should continue or not.
- Throws:
Exception
-
forwardTo
protected void forwardTo(String path, Request request, Response response) throws javax.servlet.ServletException, IOException Forwards request to JSP page. In some rare situations it is also possible to forward request to another servlet (basically even the same but with different route).- Parameters:
path
- Path to JSP page (or servlet).request
- Request object to be passed to JSP page.response
- Response object to be passed to JSP page.- Throws:
javax.servlet.ServletException
IOException
-