• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Are JSPs really Servlets ?

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 8946
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Barry's not gonna like this. Barry's not gonna like this one bit. What is Barry's deal with tiny ads?
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic