How Ajax makes the data retrieval faster than Struts?

317 Views Asked by At

I have worked with struts 1,2 for around an year. Now I need to work on DWR which is nothing but an easy way of using ajax.

So this question is about how ajax make the data retrieval from server very fast as compared to struts. I did surf thru many articles on net. I came up with this understanding that in case of struts complete forms/form data get submitted and after data retrieaval complete page gets loaded which is not the case with ajax.

What happens in ajax is we hit the required java class on server with the minimal data we need to send and after returning from server that particular ui element is refreshed which is main reason why it is faster.

Is it correct?

2

There are 2 best solutions below

0
On BEST ANSWER

Yes, it is correct. AJAX allows loading only portions of a page.

It doesn't mean it's necessarily faster, though. If each click consists in making 5 requests to refresh 5 parts, there is a good chance a single request to refresh the wole page will be faster.

As always, AJAX is only a tool. If used badly, it won't lead to good results.

0
On

Well you have taken the whole concept wrong.there is no way to compare Struts or any other framework with Ajax. Ajax is the way to load a small chunk of data from the server based on the user requirement.Ajax is being in to the market place to enhance the user experience so that we need not to refresh the page every time we want some part of the page to get changed.

On the other hand struts1/struts2 or any other MVC based framework (Spring MVC/Wicket) etc are there to build a complete web-application and you can take Ajax as a tool to enhance the user experience.

in short no need to compare two different things as they are both in place for different reasons