• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Response Filtering Suggestions

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

I am trying developa response filter, the requirement is as follows.

1.) The Filter should get the request and response object and should send a wrapped Response object to the filter.

2.) The wrapped response object should not write any thing to the browser, all the response. write, println should be captured in a stringbuffer

3.) Once the servlet returns, I should be able to check the StringBuffer response and if I get a undesired response then I will set the status as 500 and return to browser else I would send a content of string Buffer and send the same back to browser.


Please note: - As my application is running on another application ( Something like CMS) I wouldn't be able to access any of the J2EE implicit objects in any of the servlets, The only solution is to design the above response filter.

I have designed the response filter, can any one guide on how to design the Response wrapper
[ December 11, 2007: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by siva kumar:
response and if I get a undesired response then ...



How are you defining an 'undesirable response'?
What are you checking for?
 
siva kumar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi...,

Here un-desirable response is some information that comes from the CMS tool

Such as "an error occured please try again"

Basically the CMS server if any error occurs automatically re-directs to its custom error page. ( With a response status as 200 OK)

Now whenever I get the response from the custom error page I should interrupt the response and set the status as 500 ----

why I would do that, is because we are feeding our html into some third party tool. which is configured in such a manner that it will reject and will not process if the status is 500.

Please note : the CMS vendor is no longer supporting the product (Infact he has closed down) and we dont have CMS source code.
I couldnt decompile CMS code as the vendor has encrypted the code using a scrambler.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're using a Servlet Spec 2.4 compliant container, you should be able to filter requests (either forwarded or redirected to) for the custom error page itself and return you're own message, plus whatever response code you like.

That seems like it would be easier than parsing the entire response.
 
siva kumar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ben,

Thanks for your reply.

But I dont understand the solution, can you please provide some sample code.

Is there a any specific way we can do this without using response wapper.

Any guidance on this would be really great.
 
siva kumar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ben,

Sorry I forgot to update

1.) The custom error page is not being called directly from the client browser,The error.jsp is called by home.jsp only when an error occured the calling is done via request dispatcher.

2.) The worst thing with this tool is that you cannot have any servlets and JSP's called explictly there is a special RequestProcessor servlet and all calls will go via request processor servlet the URL for my home page will be some thing like

www.xxxx.com/RequestProcessor?render=home.jsp

where requestprocessor is the servlet given by CMS vendor and render is a parameter passed to resquestprocessor

thats the reason in home.jsp we cannot access any JSP/Servlet Implict Objects

If in need to add a filter I can add it only for Filter mapping ie /RequestProcessor/
 
siva kumar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

Any solutions/Suggestion on the above problem, I agree that this a peculiar problem, but surely some one might have seen simillar issues in their projects.

As I am struck any help would be really great, I hope I have explained the problem clearly if not kindly send me a message.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic