• Post Reply Bookmark Topic Watch Topic
  • New Topic

servlets&jsp

 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the exact differece between jsp and servlets?

I want the answer practically not bookish.

Thanks
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have any idea as what was the reason for making jsp's which are eventually servlets?

Have you tried to write a servlet that would render a complicated HTML chunk.In this case you will notice that there are lots of HTML snippets within the servlet code.
Even the readability of the servlet code decreases.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A JSP looks like an HTML page and ideally has no Java on it (a rule I haven't learned how to follow, BTW) while a servlet looks like a plain Java class and has no HTML.

Servlets are very good for receiving inbound GET and POST requests and figuring out what business activity needs to run. Then they can "forward" to a JSP which formats the HTML response to the user.

This kind of thing is common:
 
Krithika Srinath
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While you delier your business application, servlets are delivered as .class files (source code not available for the end user) and JSPs are delivered as .jsp (source code available for the end user).

...One more reason to use only servlets (not JSP) for implementing only business logics.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP is a templating technology for building text-based respnses, most oftien HTML pages. It just happens to be built in servlet technology.
 
siva kumar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...

I have worked in a java crm designed and developed using servlets only....that was in cira 2000

Later we developed the same app in ASP and frankly ASP was like heaven

Now all html has to be embedded in servlets using out.println's

Try to embedded a complex html page with lot of javascript( Spice added)

into a servlets.

I promise you will be dreaming about single quotes/double Quotes and escape slashes

I think that will be really a pratical night mare...
 
goli reddy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jsp
separate the presentation and business logic.(custom tags)
more easy to learn,easy to write
servlet
presentation and business logic in same place.
everything should embedd in out.println("") it is too complex to write is it?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!