Translation and compilation happens only ONCE
When you deploy a web app with a JSP, the whole translation and compilation step happens only once in the JSP’s life. Once it’s been translated and compiled, it’s just like any other servlet. And just like any other servlet, once that servlet has been loaded and initialized, the only thing that happens at request time is creation or allocation of a thread for the service method. So the picture on the previous two pages is for only the first request.

Q:
Q: OK, so that means only the first client to ask for the JSP takes the big hit. But there MUST be a way to configure the server to pre-translate and compile...right?
A:
A: Although it’s only the first client that has to wait, most Container vendors DO give you a way to ask for the whole translation/compilation thing to happen in advance, so that even the first request happens like any other servlet request.
But watch out—it’s vendor-dependent and not guaranteed. There IS a mention in the JSP spec (JSP 11.4.2) of a suggested protocol for JSP precompilation. You make a request for the JSP appending a query string “?jsp_precompile”, and the Container might (if it chooses) do the translation/compilation right then instead of waiting for the first real request.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access