You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by dg...@apache.org on 2003/07/14 01:37:30 UTC
cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/logic ForwardTag.java
dgraham 2003/07/13 16:37:30
Modified: src/share/org/apache/struts/taglib/logic ForwardTag.java
Log:
Refactored functionality into new doForward() and doRedirect() methods.
Revision Changes Path
1.16 +50 -31 jakarta-struts/src/share/org/apache/struts/taglib/logic/ForwardTag.java
Index: ForwardTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/ForwardTag.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ForwardTag.java 13 Jul 2003 23:33:27 -0000 1.15
+++ ForwardTag.java 13 Jul 2003 23:37:30 -0000 1.16
@@ -144,39 +144,58 @@
path = config.getPrefix() + path;
if (forward.getRedirect()) {
- HttpServletRequest request =
- (HttpServletRequest) pageContext.getRequest();
-
- HttpServletResponse response =
- (HttpServletResponse) pageContext.getResponse();
-
- try {
- if (path.startsWith("/")) {
- path = request.getContextPath() + path;
- }
- response.sendRedirect(response.encodeRedirectURL(path));
-
- } catch (Exception e) {
- RequestUtils.saveException(pageContext, e);
- throw new JspException(
- messages.getMessage("forward.redirect", name, e.toString()));
- }
-
+ this.doRedirect(path);
} else {
-
- try {
- pageContext.forward(path);
-
- } catch (Exception e) {
- RequestUtils.saveException(pageContext, e);
- throw new JspException(
- messages.getMessage("forward.forward", name, e.toString()));
- }
+ this.doForward(path);
}
// Skip the remainder of this page
return (SKIP_PAGE);
+ }
+
+ /**
+ * Forward to the given path converting exceptions to JspException.
+ * @param path The path to forward to.
+ * @throws JspException
+ * @since Struts 1.2
+ */
+ protected void doForward(String path) throws JspException {
+ try {
+ pageContext.forward(path);
+
+ } catch (Exception e) {
+ RequestUtils.saveException(pageContext, e);
+ throw new JspException(
+ messages.getMessage("forward.forward", name, e.toString()));
+ }
+ }
+
+ /**
+ * Redirect to the given path converting exceptions to JspException.
+ * @param path The path to redirect to.
+ * @throws JspException
+ * @since Struts 1.2
+ */
+ protected void doRedirect(String path) throws JspException {
+ HttpServletRequest request =
+ (HttpServletRequest) pageContext.getRequest();
+
+ HttpServletResponse response =
+ (HttpServletResponse) pageContext.getResponse();
+
+ try {
+ if (path.startsWith("/")) {
+ path = request.getContextPath() + path;
+ }
+
+ response.sendRedirect(response.encodeRedirectURL(path));
+
+ } catch (Exception e) {
+ RequestUtils.saveException(pageContext, e);
+ throw new JspException(
+ messages.getMessage("forward.redirect", name, e.toString()));
+ }
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org