Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Struts2 Filter and Includes

 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still get the same error.
 
J J Wright
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll try it with an earlier release and see what happens
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm running 2.1.6.
 
J J Wright
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just tried the same example with 2.0.14 and everything worked as expected.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic