Note to self
Code, cooking, catman
Friday, February 09, 2007
How to make a redirect servlet
make a servlet which calls the following method on doPost() and on doGet()
private void doRedirect(HttpServletRequest request, HttpServletResponse response) throws ServletException {
String servletPath = request.getServletPath();
//do something with the path
String newServletPath = servletPath.toLowerCase();
try {
getServletContext().getRequestDispatcher(newServletPath).forward(request, response);
} catch(IOException ioE) {
throw new ServletException("Unable to forward request: " + servletPath + " to path: " + newServletPath, ioE);
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment