Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP translation into servlet's doGet/doPost method

 
Sambuddha Roy
Greenhorn
Posts: 7
Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have the below piece of code in my jsp page.


Now I am trying to run this jsp, it will be translated into servlet. When i checked the generated servlet I found both the above code snippet(scriplet and expression) came in to _jspService method. But in the internet and in many other book i found that scriplet and expression portions will come in the doGet/doPost method (which will be called from jspservice).

So any specific reason why in this case it went in to jspservice method (though I am getting desired output)?
I am using tomcat 6.


Thanks
 
Tim Holloway
Bartender
Posts: 18423
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, doGet and doPost of HttpServlet are both invoked from the service() method, which acts sort of as a "switch" statement, invoking the appropriate "do" method based on the HTTP directive used. I haven't looked at java code generated from servlets in a while, but I suspect that _jspService may be invoked directly from an override of the service() method, as there's no such thing as a "GET" JSP or "POST" JSP as such.

Certain parties here will be quick to admonish you that if you're putting enough code in your JSPs that you need to see the generated Java, then You're Doing It Wrong, however.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!