Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Check http response of an external application from sightly code

Avatar

Avatar
Validate 25
Level 3
DEBAL_DAS
Level 3

Likes

13 likes

Total Posts

82 posts

Correct Reply

2 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile

Avatar
Validate 25
Level 3
DEBAL_DAS
Level 3

Likes

13 likes

Total Posts

82 posts

Correct Reply

2 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile
DEBAL_DAS
Level 3

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Springboard
Level 1
rakz_r
Level 1

Like

1 like

Total Posts

7 posts

Correct Reply

1 solution
Top badges earned
Springboard
Establish
Give Back
Ignite 1
Validate 1
View profile

Avatar
Springboard
Level 1
rakz_r
Level 1

Like

1 like

Total Posts

7 posts

Correct Reply

1 solution
Top badges earned
Springboard
Establish
Give Back
Ignite 1
Validate 1
View profile
rakz_r
Level 1

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.

Answers (3)

Answers (3)

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,081 likes

Total Posts

3,121 posts

Correct Reply

1,061 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,081 likes

Total Posts

3,121 posts

Correct Reply

1,061 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

06-12-2017

Please ask your architect, if you are supposed to do a clientside integration of that piece of frontend content or if you are supposed to deliver a single HTML page, which contains all data already.

The decision to use AJAX or not is something I would never leave to any single developer. It must to decision shared with the whole team, and the consequences should be very clear to all.

Jörg

Avatar

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

440 likes

Total Posts

1,016 posts

Correct Reply

115 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

440 likes

Total Posts

1,016 posts

Correct Reply

115 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile
Veena_Vikram
MVP

06-12-2017

Hi Debal

     Decide on the approach keeping how you want to handle the request. If you write a server side code, the responses are going to get cached and you might have to clear it out before you pull in a new request or some how you have to disable the cache for the same.

     If you don't need to cache , may be you can figure out to use clientside (ajax call). But then may be you have to figure out how you are going to handle the response. If it is just to display on the page a simple ajax call would do.

Thanks

Veena

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

06-12-2017

For this - make your call from HTL backend - like WCMUsePojo. Follow the way we did in invoking a RESTFUL service - Creating an Adobe Experience Manager 6.3 HTL Component that displays data from a Restful Web Service