Skip navigation
durganuvvula
Currently Being Moderated

Once apache webserver dispatches the request to CQ, where would it hit the CQ at first?

Apr 24, 2012 11:07 PM

I have a apache webserver which have a dispatcher configured. once dispatcher dispatches the request to CQ, where would it hit the CQ server at first. I need to write my own business logic at that place to do some business processing, where the request is intercepted for the first time in CQ server.

 

I am yet to start working on this requirement but I assume it is sling servlet engine by looking at the architecture of CQ and I need to write my own business logic there in the sling servlet layer and bundle the sling jar and load my bundle jar into the apache felix to solve my use case.

 

Any suggestions/pointers to solve this problem would be appreciable.

 

--Durga

 
Replies
  • Justin Edelson
    276 posts
    Nov 24, 2010
    Currently Being Moderated
    Apr 25, 2012 8:22 AM   in reply to durganuvvula

    Hi Durga,

    You would generally use a Servlet Filter for this. There are two potential insertion points:

     

    1) Before CQ (really Sling) gets the request. This type of Filter needs to be registered with the HttpService implementation. See http://felix.apache.org/site/apache-felix-http-service.html#ApacheFeli xHTTPService-UsingtheExtHttpService and http://felix.apache.org/site/apache-felix-http-service.html#ApacheFeli xHTTPService-UsingtheWhiteboard for information on this.

    2) After CQ (again, really Sling) authenticates the user and resolved the requested resource. This type of Filter is registered with the Sling Engine. See http://sling.apache.org/site/filters.html for information on Sling's Filter support.

     

    Which of these is appropriate depends upon the type of logic you need to inject.

     

    Justin

     
    |
    Mark as:
  • Justin Edelson
    276 posts
    Nov 24, 2010
    Currently Being Moderated
    Apr 30, 2012 10:32 AM   in reply to durganuvvula

    Durga-

    I believe the problem with your code is that the reponse is being flushed. This commits the response and you can't use forward after the response has been committed. See the JavaDoc here: http://docs.oracle.com/javaee/5/api/javax/servlet/RequestDispatcher.ht ml#forward%28javax.servlet.ServletRequest,%20javax.servlet.ServletResp onse%29

     

    This is the exception I see logged:

     

    30.04.2012 13:29:41.475 *INFO* [127.0.0.1 [1335806981472] GET /testVanityFilter HTTP/1.1] servletengine Servlet threw exception:  javax.servlet.ServletException: Response has been committed

     

    Regards,

    Justin

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points