File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts2 Extending the FilterDispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 Extending the FilterDispatcher" Watch "Struts2 Extending the FilterDispatcher" New topic

Struts2 Extending the FilterDispatcher

RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528

Will it be a good practice to extend the Struts Fraewroks FilterDispatcher ?

I am trying to use Hibernate with Struts .Will it be a good pratice if i extend the FilterDispacther for calling Hibernate Utility classes ??

Anyone any views i want to discuss the Pros and cons with this approach.

If you want something you never had do something which you had never done
David Newton

Joined: Sep 29, 2008
Posts: 12617

There is absolutely no reason to extend the dispatcher to do anything with Hibernate; this kind of thing is precisely what interceptors are for.

I'm assuming you're taking about creating an open-session-in-view-/OPSiV-style solution. Whether or not this is always the best solution is debatable; naive usage can lead to unexpected loss of performance in JSP pages due to lazy initialization.

Personally, I've switched over to using Spring's transaction support (there are similar solutions besides Spring) and have found it pretty handy. I also tend to initialize only the data I know will be used in the JSP to avoid the aforementioned performance hits, but part of that is due to some of the complicated data structures I've worked with lately and their expensive SQL queries.
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528

Now thinking to learn spring for this integration purpose.
I agree. Here's the link:
subject: Struts2 Extending the FilterDispatcher
jQuery in Action, 3rd edition