• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why do we need JSP when we have servlet

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
What are the things that I cannot do with a JSP and can only be done with Servlet?
Excepting the ease of writing Business logic and Control Logic in servlets when compared to JSPs,are there any other major advantages/differences with which we are still using Servlets?

Hope I will get an answer atleast here.
Thanks in advance
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Search this and the JSP forum.
You'll find plenty of discussion on on this topic.
 
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can find some useful information in the following thread:
Diffence Between JSP and Servlets
 
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
best way to find out the difference, is to try writing in both. you'll notice the difference pretty quickly when you start getting all those compile time errors with no idea what line they're coming from. I have a better question. what is benefit of jstl expression lang over jsp. it seems somewhat limited to me.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll have to find out about the MVC pattern, and understand that both have different purposes.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by kwame Iwegbue:
I have a better question ...



kwame, please do not try to hi-jack someone else's topic with questions of your own. If you have a different question, please post your own topic.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With regards to the original question: the first time that you have to maintain or extend or fix a nasty bug in a highly complex HTML page that you built up in string buffers in a servlet, you'll know the answer to your question
 
NandaM Kishore
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your good response.
But my question is still unanswered...
While browsing and discussing I came to know a difference,"JSP is converted into servlet by the container,and all the code written inside JSP is pushed into service method of the (converted)Servlet.so ,the code that we normally wish to write in init() and destroy() methods cannot be written in JSPs"
Hope Im right and I wish such a kind of differences , which can be done by only one(either by JSP/servlet but not both) and can never done by the other
 
NandaM Kishore
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
My question is still unanswered..
Will you please put some attention on it
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you'd read about what everybody talked before, you'd understand that by yourself.
To put it simply : a servlet can play the role of a JSP, and a JSP can act as a servlet. BUT, each is considered to have separate roles. A servlet is commonly used to do some business logic, while the JSP should only be used to display stuff. That is why it is not recommended to use sciptlets in JSP.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you pound a nail with a wrench? Yes, although it's certainly more difficult than doing it with a hammer. Can you turn a bolt with a hammer? Well, yes, I suppose, if you hit it at an angle; but a wrench works far better.

The point being that, although ultimately you can write anything in assembly language, in general it's best to use a language or tool that sets up an abstraction that's not far from what you need to accomplish. If you need to write Java code to compute something in response to a Web request, then writing a Servlet is quite convenient. If you need to display a bunch of HTML and include a value or two from Java, then a JSP is a far better choice. Could you use Servlets in both cases? Yes, but it would be harder. Could you use a JSP in both cases? Yes, but again, it would be harder.

Choosing the proper tool for the proper job makes life easier and more pleasant, and you get more done with less effort. Do you really not understand this, or do you just enjoy arguing?
 
NandaM Kishore
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Thanks Satou...
But I think you have not read the question that I have posted fort h 2nd time.
I know JSPs are for presentation Logic and Servlets are for Control Logic and Business Logic.and I understand they have their own purposes.
But my question is.....tell me those situations where JSPs is the only solution and not Servlets(don't say for presentation again) and vice versa.
To make yourself clear read my earlier mail
Thanks in Advance
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Choosing the proper tool for the proper job makes life easier and more pleasant


Personnally, I prefer soft toilet tissue, rather than tree leaves
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

tell me those situations where JSPs is the only solution and not Servlets


Can't think of any. JSP will never be the only solution, I think.
I've never heard "Obiwankenobi, we have to do this in JSP, that's our only hope"
 
NandaM Kishore
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Earnest......If you feel that I enjoy Arguing.....then,Im Sorry
Im looking for the perfect answer..and nothing else
 
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by NandaM Kishore:

But my question is.....tell me those situations where JSPs is the only solution and not Servlets(don't say for presentation again) and vice versa.



If you deploy your servlets in a web server/web hosting and there is no immediately reflection on your program changes, you will consider to write them in JSPs.
 
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Servlets are server extensions and provide extra functionality to the main server. For example this functionality includes the implementation of specialized services such as authentication, authorization, database validation, transaction management etc. On the other hand JSP pages can be used for display purpose only. This is the main difference between servlets & JSP.
I hope, The rest of the differences already you know.

bye for now
sat
 
reply
    Bookmark Topic Watch Topic
  • New Topic