Check http response of an external application from sightly code

Avatar

Avatar

DEBAL_DAS

Avatar

DEBAL_DAS

DEBAL_DAS

06-12-2017

Hi All,

I am planing to check the Http response of an external application from my sightly component.

From development perspective which one is better -

1. Make ajax call to check the application response code from sightly component itself.

                      

                                 or

2. Write a back end logic using WCMPojo with HttpURLConnection and validate the response.

                                   

                                or

3. Crate a servlet, get the response using HttpURLConnection and make a ajax call to that servlet  from sightly component.

Please suggest.

Thanks,

Debal

View Entire Topic

Avatar

Avatar

Rakesh_Rangaraj

Avatar

Rakesh_Rangaraj

Rakesh_Rangaraj

06-12-2017

For Point 1: You need CORS enabled for the service to be consumed if you want to make Ajax call from a sightly component.

For Point 2: If you are going to use WCMPojo, you should be taking cache and clear the responses and its tied to the component.

For Point 3: Create a common servlet to pass on the response code through HttpURL Connection to servlet response and read it through any component however you want it. Here again, you should be taking care of cache and clear the responses but the code is common and can be used in any component and externalize the URL you want to call in the servlet.

I will leave it to you on how you want to implement. I prefer option 3.