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.
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.
An IDE is no substitute for an Intelligent Developer.