Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 Filter and Includes

 
J J Wright
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to invoke a Struts2 action using <jsp:include> (I can't use <:s:action> because it doesn't result in a new request, and I need to be able to cache the response from the included action using a Servlet filter.). However, when I set up my Struts filter to handle includes



I get the following exception in Glassfish V2.1. Any suggestions?

 
J J Wright
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This doesn't work in Tomcat 6 either so I guess its a limitation / problem with Struts 2.1.6. I have to day I find it incredible you can't perform a JSP include on a Struts action.

I have a suspicion it will work when I use org.apache.struts2.dispatcher.ng.servlet.StrutsServlet as opposed to org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter. However, the API docs contain the following warning for using StrutsServlet:

This servlet dispatcher is only for those that really know what they are doing as it may not support every feature of Struts, particularly static resource serving.


All in all pretty disappointing - I may end up ditching Struts2 altogether.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no issues using <jsp:include> to include an action.
Your server wrote:
javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20

That error message leads me to believe it's either a recursive include, or you're doing something else funky, but that's just an off-the-cuff guess.
 
J J Wright
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply,

How is your Struts filter set up? By default it won't process includes - did you have you add <dispatcher>INCLUDE</dispatcher>?




 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep; I used the configuration you showed in the first message.
 
J J Wright
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David,

I've attached the offending code for a very basic test. I'm assuming I must be doing something glaringly obvious wrong, but I can't see it.



Thanks very much for your help.

Jonathan

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you use "date.action" as the page? (Or "/date.action"?)
 
J J Wright
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still get the same error.
 
J J Wright
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll try it with an earlier release and see what happens
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm running 2.1.6.
 
J J Wright
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just tried the same example with 2.0.14 and everything worked as expected.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic