Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet/JSP creation/ invokation process?!

 
mark evertz
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
Thanks,
Mark
 
Peter Gragert
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 http://www.devx.com/premier/mgznarch/javapro/2002/04apr02/th0402/th0402-1.asp
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic