Please bear with me, I am still pretty new to Java. I am trying to create a web report with JSP and Servlets under Tomcat5. This reports has several independent pieces, so I would like to make the report modular, with a servlet for each piece to perform the necessary data access and logic.
I was hoping to design it in the following way: Each servlet would perform it's logic, write the results to a bean, and then forward to a JSP Fragment (.jspf). Then I would have a main JSP page that would just include each servlet that I needed (hence getting the output from the JSP Fragments). That way I could add or remove each piece with ease from the JSP.
I have begun to realize, however, that this doesn't work. Because of the nature of JSPs & Servlets, the jspf that the servlet forwards to doesn't get parsed. Instead, it's code is written to the browser where it is included. I obviously need to change the way I'm doing things, but I am not sure how. How do I keep this modular? Thanks.
... Because of the nature of JSPs & Servlets, the jspf that the servlet forwards to doesn't get parsed. Instead, it's code is written to the browser where it is included.
This is not correct. If your JSP code is ever sent to the browser something is wrong. As Bear mentioned, and you have probably noticed, jspf files are parsed on the server; but only when they are statically included.
When you get a chance, read this entry in our JspFaq. It covers the difference between the two include mechanisms in JSP.