File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Concepts | Using servlet filter within a struts application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Concepts | Using servlet filter within a struts application" Watch "Concepts | Using servlet filter within a struts application" New topic
Author

Concepts | Using servlet filter within a struts application

jazz pal
Greenhorn

Joined: Mar 15, 2011
Posts: 7
Environment: Struts 1.1. Tomcat 6, Eclipse 3.6
Business Objective: Invoke an application(e.g. App B) from within an existing application (e.g. App A) based on certain criteria.
Tech Objective: Use Servlet Filter to catch a request from App A if its has a specific URL pattern and create a new request to App B.
Tech Design
1. I have defined a filter in my web.xml which looks for a specific URL pattern.
2. From my action class execute method I do a ActionMapping.findForward to a string expecting that web.xml entry for filter will match and filter class get executed

Issue
The control rather goes to the struts-config.xml and there by totally bypassing the web.xml

Questions
1. What's the best way to achieve what I'm intending to do? if not then how can this be achieved?

Thanks
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
You can't bypass giving "control" to your web.xml, your web.xml should be where you specified your servlet that runs your struts app. Are you sure you have the filter configured correctly? Posting your web.xml and the URL that the server is processing might help. Also, posting the code for your filter might help as well. Once you send your request to the other app, are you continuing with the filter chain? If so then it will probably still run the initial app.
jazz pal
Greenhorn

Joined: Mar 15, 2011
Posts: 7
So I resolved the issue. I was trying to solve the problem incorrectly.
what I wanted to achieve was to add a filter to existing application w/o making any drastic change to the existing code.
So the way I have structured the code is that my filter looks for a specific action and then starts the invocation of another application.

If anyone wants to refer to the code let me know I'll be happy to post a sample app.
Thanks
surya pavan
Greenhorn

Joined: Jun 14, 2011
Posts: 1
Hi Jazz,
Could you please post the sample app?

--
Thanks
SuryaPavan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Concepts | Using servlet filter within a struts application