Meaningless Drivel is fun!*
The moose likes JSP and the fly likes Difference Between JSP & Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Difference Between JSP & Servlets" Watch "Difference Between JSP & Servlets" New topic
Author

Difference Between JSP & Servlets

Arun Vethadas .T
Ranch Hand

Joined: Dec 13, 2001
Posts: 36
Hai
i want Difference Between JSP & Servlets
What is the advantage using JSP.
What is the advantage using Servlets in Projects.
i don't understand. pls.Help me.
Thanks,
Das.
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
first of all let me make it very clear that internally when jsp is excuted by server it get converted to servlet. So the way servlet and jsp work is almost similar. For both you need to have basic understanding of servlet life cycle and ofcouse knowledge of java.
Coming to when to use servlet or jsp. when your purpose is to render page at user end go for jsp,
else if your purpose is to do some server side validation such has database updatation etc. go for servlet.
But i want to put one point over here is that both the objective can be achived by jsp or servlet.
-arun
[ February 01, 2002: Message edited by: arun boraiah ]

Sharing is learning
Arun Vethadas .T
Ranch Hand

Joined: Dec 13, 2001
Posts: 36
Thanks for ur reply Arun.
thanks,
das.
Shehzad Khan
Greenhorn

Joined: Jan 24, 2002
Posts: 6
dear arun
may i have the opportunity to share something regarding the question thrown by you.

servlets are a very LOW-LEVEL programming
jsp is HIGH-LEVEL programming
having said that, the greatest advantage/purpose of jsp is to place a hidden or unseen wall of abstraction between presentation and implementation. this task was not achieving fully in servlets.
thanks
take care
from sk!!
Steven Kors
Ranch Hand

Joined: Jan 30, 2002
Posts: 33
Simply put in most cases you will use JSP and Servlets together. JSP helps separate the Java coders from the HTML designers.
Imagine if you will that you have a Home page that has about 100 lines of HTML and a 10 line table that is dynamically generated by selections made by the user. If you used a servlet that is fine but in order to output those 100 lines you are going to be using a LOT of println statements to facilitate that static content. Plus you have to incorporate the code that generates the dynamic table. Why not drop the HTML into a JSP page and create a servlet that generates the dynamic code. Just use the JSP tags and scripting to call the dynamic content from the servlet. This way the Java code is separated from the HTML and JSP design elements.
THere are a number of advantages for doing this.
1 you separate the Java code from the HTML (you should do this as much as possible). THis allows the Java programmers to dotheir job with out getting in the way of the HTML designers. THe HTML designers are able to modify the Page with out too much of a learning curve for the scripting elements.
2 More easily maintained. Java Coders can maintain the Java code and the HTML designers can manage the display content separately.
Just a couple of examples =).
For simple projects, sure you will use JSP and Servlets exclusively but with more complex and intricate projects you should use a combination of the two.
Hope that helps


Thanks,
Steven
Arun Vethadas .T
Ranch Hand

Joined: Dec 13, 2001
Posts: 36
Hai
Thanks for tips. It's really very helpful to me.
Thanks for everyone.
Bye.
Arun.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference Between JSP & Servlets