This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Servlets and the fly likes Servlet/JSP creation/ invokation process?! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet/JSP creation/ invokation process?!" Watch "Servlet/JSP creation/ invokation process?!" New topic

Servlet/JSP creation/ invokation process?!

mark evertz

Joined: Apr 11, 2002
Posts: 22
Can someone explain (detailed) how the creation
process of Servlets/ JSPs is working when invoked via an URL.
What I'm interested in is:
- When I call a .jsp page is there a generic servlet that interprets the whole page,
prints the static text to system.out and compiles the rest?
Does this servlet exist per Webapp, per servlet-engine, per folder - know what I mean??
I would like to know how the whole process is working.
Maybe someone can give some insights, that would great?
Peter Gragert
Ranch Hand

Joined: Jan 16, 2001
Posts: 424
To my knowledge the server gets the 'asp' code, tranlates them into a servlet and then serves the client.
Depending on filtering set in your server a lot of other things may happen too ...
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17421

I never bothered to see if it's actually MANDATORY, but in practice, all the implementations I know about convert JSPs to their corresponding servlets.
Very greatly simplified (ignoring custom tags and such), items outside the <% %> delimiters are passed verbatim to generated out.print( item outside delimiters ) statements, and items INSIDE the delimiters - which are presumed to be Java code that just gets copied into the generated servlet's source code. After that's done, the generated servlet is compiled and the compiled servlet class is executed. Often the generated servlet source code is then discarded, since it's no longer needed, but usally there's a "keep generated" option so you can debug the JSP more easily.
There ARE situations where you have a "master servlet". The most common is where the web app is based on the Model/View/Controller design pattern. Or more precisely, on patterns that have been constructed in emulation of MVC. The original MVC requires more interactivity than HTTP servers can provide.
The latest and greatest incarnation of this revised MVC architecture is "Model 2". The Jakarta Struts framework is based on this architecture. You might want to read my quick introduction to Struts at

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Servlet/JSP creation/ invokation process?!
It's not a secret anymore!