// Determine which URL to go to from which submission
// button was pressed to get here
String targetURL = null;
SessionFormData formData = pageContext.getFormDataManager().
getSessionFormData(formSpecifier);
if (request.getParameter(URLConstants.NEXT_FORM_FRAGMENT) != null) {
targetURL = formData.getFieldValue(URLConstants.NEXT_FORM_FRAGMENT);
} else if (request.getParameter(URLConstants.PREV_FORM_FRAGMENT) !=
null) {
targetURL = formData.getFieldValue(URLConstants.PREV_FORM_FRAGMENT);
} else if (request.getParameter(URLConstants.RESET_FORM_FRAGMENT) !=
null) {
targetURL = formData.getFieldValue(URLConstants.RESET_FORM_FRAGMENT);
} else {
targetURL = formData.getFieldValue(URLConstants.ACTION_FORM_FRAGMENT);
}
if (logger.isDebugEnabled()) {
logger.debug("Target URL is " + targetURL);
}
if (targetURL == null) {
requestContext.release();
throw new ServletException("No target URL for dispatch.");
}
// Strip the context path from the front of the target URL if it is
// there
targetURL = removeContextPath(targetURL, request);
// Strip the session id from the URL if there is one
targetURL = removeSession(targetURL);
// Make sure the target URL starts with a / (required by dispatcher).
if (!targetURL.startsWith("/")) {
targetURL = "/" + targetURL;
}
// Add the passed form parameters into the session
en = request.getParameterNames();
while (en.hasMoreElements()) {
String pName = (String) en.nextElement();
if (!(pName.equals(URLConstants.FORM_PARAMETER)) &&
!(pName.equals(URLConstants.NEXT_FORM_FRAGMENT)) &&
!(pName.equals(URLConstants.PREV_FORM_FRAGMENT)) &&
!(pName.equals(URLConstants.ACTION_FORM_FRAGMENT)) &&
!(pName.equals(URLConstants.
FORM_FRAGMENTATION_PARAMETER)) &&
!(pName.equals(URLConstants.RESET_FORM_FRAGMENT))) {
String pValue = (String) request.getParameter(pName);
if (logger.isDebugEnabled()) {
logger.debug("Writing attribute " + pName + "=" +
pValue + " to the session context.");
}
formData.setFieldValue(pName, pValue);
}
}
// Forward to the appropriate destination
if (logger.isDebugEnabled()) {