• Post Reply Bookmark Topic Watch Topic
  • New Topic

Which one approach is good for comunicateing data between server and JSP page?

 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I am working on a web application In which I am comunicating between my JSP page and Controller class and database.Let me explain my seneraio

1)I have a section called getAllNews I can get data first call to PageController->Page Controller call DAo and set Object is request->forward it to JSP->JSP parse using JSTL tags+Java Sccript


2)Call for front page to page controller->Page loaded->A AJAX Script will call to server and get the response of server side controller->Parse JSON using JAvaScript


Both way I can acheive same result.
My Question is IS there
1)will be any perfomance difference in two approaches?
2)Which approach is good in which seneraio?

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the content need to update after the page is loaded? If so, then the Ajax approach is best for that. But for the initial load, you might want to consider pre-loading the page with content so that there's no delay. So, sometimes, the answer is both.

That said, most often I will see Ajax used for the first load as well, which sometimes results in a momentary delay while the first content is loaded.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In My Project like this if a page is first time loaded then I use first approach

And If there any change in page without reloading the web page then I use second approach

is this fine?
 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Having two approachs for same scenario/functionality is never good idea.
Try implementing suggestion given in above post
But for the initial load, you might want to consider pre-loading the page with content so that there's no delay.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Abhay
Thanks for suggestion
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!