One more thing: Don’t think of JSP pages sitting “infront” of the Servlets on the web side… they are all equal to the app server, so it’s not like your user sends a request to the servlet, which sends it “up” to the JSP page, and then “out” to the user… instead it is more like all the servlets and JSP pages being side-by-side like this:
[Servlet] [JSP Page] [JSP Page] [Servlet]
And the Servlet or JSP page can write content back to the client using the PrintWriter… OR they can optionally store some data in a hashtable (Request, Session or Application scopes are basically hashtables) and then forward control of the client sideways to the next JSP page or Servlet… until one of the JSP pages or Servlets replies to the client.
To get a better idea, load a JSP page in your app server (assuming TOmcat), then go into the work/Catalina/localhost dir and drill down to your app’s folder, then into the org/apache/… dir until you find your JSP page’s generated Java file… open it up.
Notice how ALL your HTML code got turned into:
out.write("<html> blah blah</html>");
method calls? This might just help show what happens.