|
MDi JLib 1.7.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.microdeveloper.servlets.io.PostRedirect
public class PostRedirect
PostRedirect will accept a request and redirect it as a post type request to another destination URL allowing the instantiated servlet to override certain parameters from the original post.
An example of usage would be to invoke a report, passing parameters such as order number, but letting a custom method determine the exact report to run for the given request or user. Another usage would be to validate or remove unwanted or unsafe parameters before invoking the target.
Finally, by using the redirection, the actual target is not visible in the URL.
Constructor Summary | |
---|---|
PostRedirect()
|
Method Summary | |
---|---|
void |
destroy()
Destroys the servlet. |
protected void |
doGet(HttpServletRequest request,
HttpServletResponse response)
Handles the HTTP GET method. |
protected void |
doPost(HttpServletRequest request,
HttpServletResponse response)
Handles the HTTP POST method. |
String |
getServletInfo()
Returns a short description of the servlet. |
void |
init(ServletConfig config)
Initializes the servlet. |
protected void |
processRequest(HttpServletRequest request,
HttpServletResponse response)
Processes requests for both HTTP GET and POST
methods. |
void |
sendRedirect(HttpServletRequest request,
HttpServletResponse response)
Process the redirection to the destination. |
protected Hashtable |
setOverrideParams(Hashtable params)
Overrides and potentially replaces original request parameters |
protected void |
setServletProperties(String paramFile)
The servlet properties which defines the default protocol (scheme), server, port, and path. |
Methods inherited from class javax.servlet.http.HttpServlet |
---|
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
---|
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PostRedirect()
Method Detail |
---|
public String getServletInfo()
getServletInfo
in interface Servlet
getServletInfo
in class GenericServlet
public void destroy()
destroy
in interface Servlet
destroy
in class GenericServlet
public void init(ServletConfig config) throws ServletException
init
in interface Servlet
init
in class GenericServlet
config
- Configuration for the servlet
ServletException
- Standard servlet exceptionpublic void sendRedirect(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
Process the redirection to the destination. Uses customUrl to allow the overriding of the fetched parameters so they can be pre-processed by custom routines. This is not required however and the default method does nothing to the parameters unless overridden.
request
- servlet requestresponse
- servlet response
ServletException
- standard servlet exception
IOException
- standard io exceptionprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
GET
method.
doGet
in class HttpServlet
request
- servlet requestresponse
- servlet response
ServletException
- standard servlet exception
IOException
- standard io exceptionprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
POST
method.
doPost
in class HttpServlet
request
- servlet requestresponse
- servlet response
ServletException
- standard servlet exception
IOException
- standard io exceptionprotected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
GET
and POST
methods.
request
- servlet requestresponse
- servlet response
ServletException
- standard servlet exception
IOException
- standard io exceptionprotected void setServletProperties(String paramFile) throws ServletException, IOException
The servlet properties which defines the default protocol (scheme), server, port, and path. Only the default server must be set in the properties file. If this is not present, the servlet will not initialize. The default url would be HTTP://[server]:80
This method can be overriden to add additional properties, such as default database credentials, but must always include the following:
These elements must be present even if they are absent from the actual parameter file itself.
You can also use the setOverrideParams method to introduce custom parameters instead of overriding this method. Just fetch additional parameters there and add them to the post variables (for logon credentials for example)
paramFile
- full path to the parameter file
ServletException
- standard servlet exception
IOException
- standard io exceptionprotected Hashtable setOverrideParams(Hashtable params)
params
- Original request parameter Hashtable
|
MDi JLib 1.7.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |