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 Situation like this.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Situation like this.." Watch "Situation like this.." New topic
Author

Situation like this..

Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
Hi all,
Can there be any situation where we can only use Servlet & not JSP or vice versa,i.e JSP only & not Servlet.
Hope I am clear
TIA
MB


Malhar Barai
SOA & Java Book
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Sure.
If all you need is a small number of pages and a few beans, then JSP on its own is great. Likewise, if you don't need fancy HTML generation (or just don't like JSP) then you can build a perfectly reasonable web application only using servlets.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30580
    
154

Everything that can be done in JSPs can be done in servlets and vice versa. However, it can be extremely awkward to use one (such as the example Frank gave with a lot of presentation details.) It can be done with servlets, but it shouldn't.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
Hi Frank & Jeanne...
Even I was unable to guess any situation like this...also thought in the same way as Frank..If no GUI's has to be made, servlet is the best option, only if we need some sort of HTML stuff to be shown to the users, we would use JSP.
But can anyone guess some specific situation
TIA
MB
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12791
    
    5
Since JSP are designed to output a character stream it is essentially impossible to use JSP to serve binary data such as images. If your application needs to generate images or sounds on the fly, you are going to end up using servlets.
Bill
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30580
    
154

While it is possible to do almost anything (including generating binary data) with servlets, it is not always a good idea. You could stick whatever code would be in the servlet inside a JSP scriplet. However, this is poor style and should be avoided. But it can be done.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Situation like this..