• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference Between JSP & Servlets

 
Arun Vethadas .T
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 233
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Arun Vethadas .T
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for ur reply Arun.
thanks,
das.
 
Shehzad Khan
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Arun Vethadas .T
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai
Thanks for tips. It's really very helpful to me.
Thanks for everyone.
Bye.
Arun.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic