aspose file tools*
The moose likes Servlets and the fly likes Are JSPs really Servlets ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Are JSPs really Servlets ?" Watch "Are JSPs really Servlets ?" New topic
Author

Are JSPs really Servlets ?

Jawahar Rajan
Ranch Hand

Joined: Feb 28, 2002
Posts: 38
All,
I recently attened a workshop on JSP's and was suprised to find out that Really JSP are nothinbg but a Servelt in disguise?
Is this true.
Well I think the Point may be valid.
Both JSP's and Servelts can generate HTML pages and have JAva code in them - Correct?
I was also informed the really when a JSP is executed it is in fact calling a servelet POST method - is this true?
My other question is about over head. are JSP's heavy components and would it be beter to have java code in a true Servelet and let JSP's handle the HTML part.
If I am building say a shopping cart example where is the best place to have the HTML for displaying a page?
Thanks
Jawahar
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Yes, you are correct in saying that JSP's are really servlets in disguise. When a JSP page it parsed, and a temporary servlet source code is created, this code is then compiled into a servlet.
No, it is not true that when a JSP page is executed it is calling a servlet POST method. It is the geenerated servlet class file that is getting called and executed. There is a lot more to it than I am posting though. It's good to get a very good understanding of servlets before taking on JSPs.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

Moreover, what u can do in 4/5 lines using JSP may take 25/30 lines code for a servlets. Also, HTML is embeded inside servlet code which again is not desirable. JSP code however must be less than 64 K, AFAIK. Pls. correct me on this one if this info is obsolete.
HTH,
- Manish
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Y SHOULD JSP COPULD BE LESS THAN 64 K?
Originally posted by Manish Hatwalne:
Moreover, what u can do in 4/5 lines using JSP may take 25/30 lines code for a servlets. Also, HTML is embeded inside servlet code which again is not desirable. JSP code however must be less than 64 K, AFAIK. Pls. correct me on this one if this info is obsolete.
HTH,
- Manish


Groovy
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
There is a 64k limit on the size of any object when it is compiled into a class file. JSP source is compiled by the JSP container into a class file so that it can be executed on each request, so you can occasionally come up against this class file size limit if you write long JSPs with a lot of explicit HTML.
The solution is usually to break the text up somehow :- either split the page into several separate JSPs and "include" them when the main pag is displayed, or load the page text from somewhere else (a file, JNDI, a session, another URL, a ResourceBundle, a database etc etc.) and show it under program control.
In general, though, you shouldn't need to worry about it until you get a class file size exceeded error message, then remember this thread!


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
Don't get me started about those stupid light bulbs.
 
subject: Are JSPs really Servlets ?