Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

servlet is for business logic and jsp is for view  RSS feed

 
sai prasanna
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

I can do every thing using servlet itself,then what is the need of using jsp? in which situation ,we must use servlet or jsp or both?

the answer is jsp is for view and again jsp is converted to servlet .servlet is for business logic. please explain

thanks in advance
saiprasanna
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP's are 'good' at outputting HTML, but they get nasty if you put too much code in them. Therefore they work well for display (html) but badly for logic (ie heavy code). There are other strong reasons why separation is a good idea, but this is the basis for the difference in JSP/Servlets.
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

servlet is for business logic.


NO. Servlet are like middle man mediating between the java classes(or)EJB beans[Model] and jsp pages[view].

They are known as Controller.

Search this forum with the keyword "MVC" to learn more about why exactly we need something called servlets in our web application.
 
Martin Simons
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't mean to disagree, just to disagree, but my view is that servlet
and jsp are, in end effect, exactly the same thing. Both take the form
of the controller in MVC (the browser is the view). It is simply that
many programmers are more likely to stick business logic into the servlet
itself than they are to do so in a JSP. It is wrong to do so in either
case, at least from the MVC program design. But, then again, that is still
only one possible design model.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaRanchs own Bear Bibeault wrote an article on the subject that sorts out M, V, C and a few other things very nicely.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!