aspose file tools*
The moose likes Struts and the fly likes Using struts 2 tags with *.action filter mapping in web.xml throws a jasper exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Using struts 2 tags with *.action filter mapping in web.xml throws a jasper exception" Watch "Using struts 2 tags with *.action filter mapping in web.xml throws a jasper exception" New topic
Author

Using struts 2 tags with *.action filter mapping in web.xml throws a jasper exception

Mohamed Soliman
Greenhorn

Joined: Mar 09, 2010
Posts: 13
Dear all

I've a problem using struts 2 tags while the struts 2 filter is mapped to *.action instead of /* in web.xml as follows:

<filter>
<filter-name>Struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>Struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>

But I get the following exception:

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. - [unknown location]
org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60)
org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:44)
org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:48)
org.apache.jsp.index_jsp._jspx_meth_s_005flabel_005f0(index_jsp.java:107)
org.apache.jsp.index_jsp._jspService(index_jsp.java:78)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

is there any solution for this problem?because I dont want to use the /* mapping for struts2 in my application.
Anbarasu Aladiyan
Ranch Hand

Joined: Jun 02, 2009
Posts: 182

Mohamed Soliman wrote: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. - [unknown location]
org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60)
org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:44)
org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:48)
org.apache.jsp.index_jsp._jspx_meth_s_005flabel_005f0(index_jsp.java:107)

Servlet filter is mapped with *.action and calling index.jsp does not goes through the filter (Because index.jsp is not index.action). So we can not use struts tags in index.jsp page. If we want to use struts tags then request must pass through servlet filter. It can be done by mapping all the request to servlet filter by using /*.

In your case do not use any struts tags in index.jsp. But struts tags can be used in other pages and those pages must be accessed through servlet filter (By calling the struts action from index.jsp)


A.A.Anbarasu
Mohamed Soliman
Greenhorn

Joined: Mar 09, 2010
Posts: 13
Anbarasu Aladiyan wrote:
Mohamed Soliman wrote: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. - [unknown location]
org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60)
org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:44)
org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:48)
org.apache.jsp.index_jsp._jspx_meth_s_005flabel_005f0(index_jsp.java:107)

Servlet filter is mapped with *.action and calling index.jsp does not goes through the filter (Because index.jsp is not index.action). So we can not use struts tags in index.jsp page. If we want to use struts tags then request must pass through servlet filter. It can be done by mapping all the request to servlet filter by using /*.

In your case do not use any struts tags in index.jsp. But struts tags can be used in other pages and those pages must be accessed through servlet filter (By calling the struts action from index.jsp)


Thanks alot...it works now,,,but its kinda strange why Struts 2 custom tags have to pass through the dispatcher flter...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using struts 2 tags with *.action filter mapping in web.xml throws a jasper exception