This week's giveaway is in the Java/Jakarta EE forum.
We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line!
See  RSS feed
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.

Saloon Keeper
Posts: 19078
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!