File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 39547
    
  27
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 - updated with new look and Ping home screen widget
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: 39547
    
  27
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is the different between JSP and SERVLET
 
Similar Threads
differeance between jsp and servlet
JSP & Servlets
jsp
jsp vs servlet
comparison between JSP and Servlet