Designing JSPs to be testable outside of a running server.
Write your JSPs to use helper classes that do not depend on a running server, and then test those helper classes with JUnit.
Testing server code is challenging, as we have seen throughout this chapter. JSPs pose a greater risk of failure because multiple technologies are intermingled. JSPs mix snippets of Java code with snippets of HTML, XML, JSTL, and JavaBeans; add the deployment of JSP and the problems of testing only get worse. A better approach to designing and testing JSPs is to write support classes that do not depend on a running server to perform logic. These support classes can then be tested outside of a running server using JUnit.
Recipe 7.15 discusses testing non-server-dependent classes.