• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP more efficient than Servlet ???

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is said that in some of the books that servlet is not efficient in generating HTML and instead we should use JSP. How is JSP more efficient in generating HTML since JSP is compiled into servlet before it is run ? Can some of the wizard out there help on this.

Thank You
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i guess, the efficiency issue here is more based upon effective application design things. it might be simpler to write a simple HTML tag instead of out.println(HTML tag).
modelling like that your servlets act as the controllers and the entry-way to your business-logic (aka beans) while your jsp (which gets translated into servlets, yepp) stays quite simple and can be read/customized by e.g. webdesigners that have no clue about java programming at all.
a quickfix in design will not make your application break down, as the logic stays intact.
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess the efficiency or the usage of either JSP or Servlets depends on the scenario on which one is working for example if one has to write an exhaustive HTML code and very little logic he can go for a JSP as it is very simple to format HTML in a JSP as compared to a Servlet.On the other hand if one wants to execute some logic processing code than he can opt for a Servlet (e.g. a Controller) which can than forward the request to a JSP page for the view.
One advantage of using JSP's is that you dont have to Compile the generated servlet classes yourself, the Container does it for you which is contrary to a Servlet. But some may feel that it is additional performance hit on the container in case one makes changes to a JSP.

So i would conclude that the efficiency of either JSP or Servlets depends on the design of one's Application and the knowledge about when should one use a JSP or a Servlet.

Regards,
Saurabh
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jaime Yong:
It is said that in some of the books that servlet is not efficient in generating HTML and instead we should use JSP.



I'm pretty sure that efficiency here refers to the velocity of the programmer, not the server. You can code JSPs a ton faster than html-heavy servlets.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic