Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the different between JSP and SERVLET

 
sureshkumar settu
Greenhorn
Posts: 16
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to know what is the difference between JSP and SERVLET. when you say JSP it will automatically converted in to Servlet then why all the developers are mentioning that we should call DAO from servlet only not by JSP.

Is there any particualr reason to use only SERVLET. please let me know if you have an answer.
 
sudhir nim
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, tht's true that every JSP is ultimately converted to servlet, but that doesnt mean, you should start writing all your application logic in a JSP.
JSP is designed to be used as views/for generating markup. Its not good practice to put lots of java code into JSP.
See this for difference
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its not good practice to put lots of java code into JSP.

In fact, it's quite bad practice. There should be no Java code in JSPs. See Scriptless JSP Pages: The Front Man for more details.
 
sudhir nim
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote: There should be no Java code in JSPs.


That's true, but most of the beginners find it difficult to have complete java less JSP.
I personally prefer freemarker, so there's no choice of writing code into template.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
most of the beginners find it difficult to have complete java less JSP.

Possibly, but it's still much easier to start off using proper techniques than to learn bad practices and try to shed them later. No responsible professional should advocate keeping any amount of Java code in JSPs these days.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic