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
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
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
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
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!