• Post Reply Bookmark Topic Watch Topic
  • New Topic

what is the good approach of passing request to the controller/servlet  RSS feed

 
Punit Jain
Ranch Hand
Posts: 1028
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i have used jsp's to passing request to the servlet or controllers.
but we can also pass request from javascript using ajax and sending data using json.

what is the good approach and why?

or does it depends on the situations? is yes, what kind of situations?

Thanks,
Punit
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, all means have their place. At a very high level: you'd use a "normal" submission when you want the entire page to be refreshed, and an Ajax request when you don't.
 
Mohnish Dukhande
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should ask yourself question,I want to refresh entire page or part of it?If your answer is entire page go for jsp else ajax.Also, think what type of data you will need as response i.e. you will get back either json or XML from ajax call and from jsp you can get different type of data e.g html data
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohnish Dukhande wrote:If your answer is entire page go for jsp else ajax

JSP is irrelevant here. Whether a page submission goes to a JSP (or servlet, or PHP, or...) or not is moot.

Also, think what type of data you will need as response i.e. you will get back either json or XML from ajax call and from jsp you can get different type of data e.g html data

Certainly if data (JSON et al) is being returned, Ajax is indicated. But Ajax is also often used to fetch HTML code snippets, so just because HTML is the response type is not a reason to eschew Ajax.
 
Anindya Roy
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check what kind of application you are going to deal with. whether you really need to apply AJAX to your application page. who are the end users and how the page should be accessed.
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll add my two cents worth here. If you want to modify part of the page that the user is currently viewing, use Ajax. If the user action (button click or link or whatever) will take them to an entirely new page then use a regular post or get such as in a form submission.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!