Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes What is the different between JSP and SERVLET Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "What is the different between JSP and SERVLET" Watch "What is the different between JSP and SERVLET" New topic
Author

What is the different between JSP and SERVLET

sureshkumar settu
Greenhorn

Joined: May 05, 2010
Posts: 16

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

Joined: Aug 29, 2007
Posts: 212

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


[Servlet tutorial] [Servlet 3.0 Cook Book]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41049
    
  43
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.


Ping & DNS - my free Android networking tools app
sudhir nim
Ranch Hand

Joined: Aug 29, 2007
Posts: 212

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
Marshal

Joined: Mar 22, 2005
Posts: 41049
    
  43
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: What is the different between JSP and SERVLET
 
Similar Threads
differeance between jsp and servlet
comparison between JSP and Servlet
jsp
JSP & Servlets
jsp vs servlet