From 66bec3e8ab5920d756aa4ca49ce4ff88bfcb93da Mon Sep 17 00:00:00 2001 From: "Donald J. Brown" Date: Mon, 3 Sep 2007 03:24:53 +0000 Subject: [PATCH] Adding better error message when a Struts tag is used w/o the servlet filter WW-1969 git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@572225 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/struts2/views/jsp/TagUtils.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/src/main/java/org/apache/struts2/views/jsp/TagUtils.java b/core/src/main/java/org/apache/struts2/views/jsp/TagUtils.java index 4aeb91ec5..5d1a12367 100644 --- a/core/src/main/java/org/apache/struts2/views/jsp/TagUtils.java +++ b/core/src/main/java/org/apache/struts2/views/jsp/TagUtils.java @@ -38,6 +38,7 @@ import org.apache.struts2.util.AttributeMap; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; +import com.opensymphony.xwork2.config.ConfigurationException; import com.opensymphony.xwork2.util.ValueStack; import com.opensymphony.xwork2.util.ValueStackFactory; @@ -55,6 +56,11 @@ public class TagUtils { HttpServletResponse res = (HttpServletResponse) pageContext.getResponse(); Dispatcher du = Dispatcher.getInstance(); + if (du == null) { + throw new ConfigurationException("The Struts dispatcher cannot be found. This is usually caused by "+ + "using Struts tags without the associated filter. Struts tags are only usable when the request "+ + "has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag."); + } Map extraContext = du.createContextMap(new RequestMap(req), req.getParameterMap(), new SessionMap(req),