* @param forwardConfig The forward to be performed
*/
protected void perform(Context context,ForwardConfig forwardConfig)
throws Exception {
ServletWebContext swcontext = (ServletWebContext) context;
String forwardPath = forwardConfig.getPath();
String uri = null;
ModuleConfig moduleConfig = (ModuleConfig) context.get(getModuleConfigKey());
// Resolve module-relative paths
if (forwardPath.startsWith("/")) {
uri = RequestUtils.forwardURL(swcontext.getRequest(),
forwardConfig,
moduleConfig);
} else {
uri = forwardPath;
}
// Get the underlying request in the case of a multipart wrapper
HttpServletRequest request = swcontext.getRequest();
if (request instanceof MultipartRequestWrapper) {
request = ((MultipartRequestWrapper) request).getRequest();
}
// Perform redirect or forward
if (forwardConfig.getRedirect()) {
if (uri.startsWith("/")) {
uri = request.getContextPath() + uri;
}
swcontext.getResponse().sendRedirect
(swcontext.getResponse().encodeRedirectURL(uri));
} else {
RequestDispatcher rd =
swcontext.getContext().getRequestDispatcher(uri);
rd.forward(request, swcontext.getResponse());
}
}