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

service() and _jspService() methods

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How does the servlet container differentiate between service() and _jspService() methods?
 
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
When the JSP file is processed to generate a Servlet, the JSP processor makes one which conforms to the Servlet API specification, and thus includes a "service" method. Depending on the particular JSP implementation it can do that by inheriting from some generic JSPServlet class or by actually coding it all in the generated servlet. This method does some stuff, then calls a _jspService method. which is also generated in the same way.
As far as the container is concerned, there is only a "service" method, and that's what it calls.
 
vidula kulkarni
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!! But can u elaborate more?<br> When a jsp is complied,the generated servlet has the _jspService() mtd.There is no implementation for the service() method.
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The translated JSPs (Servlets) generally extend a container specific superclass where all this sort of stuff is implemented.
Simon
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The container generated servlet class implements interface 'HttpJspPage' which extends 'JspPage' which in turn extends 'Servlet' interface.
Servlet
1. init(config)
2. public service(req, res)
3. destroy() and others
JspPage extends Servlet and adds
1. jspInit()
2. jspDestroy()
HttpJspPage extends JspPage and adds
1. _jspService(req,res)
So essentially the generated servlet implements all the above listed methods. Some containers have a superclass which has all the above methods implementations done already. The only one method which is generated at the time our jsp's servlet is compiled is, the _jspService(req,res) which is added on the fly during compilation.
As far as the container is concerned, it calls the public Service(req,res) method only. This public service(req,res) method in turn calls _jspService(req,res) in generated servlet.
Regards,
Maha Anna
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic