This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Concepts | Using servlet filter within a struts application

 
jazz pal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jazz,
Could you please post the sample app?

--
Thanks
SuryaPavan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic