Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

servlet is for business logic and jsp is for view

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic