JSP Tag Libraries

Скачать в pdf «JSP Tag Libraries»

out.write(«rnYou asked for the server «); out.print( request.getServerName() ); out.write(«rn»);



} catch(Exception ex) {

if(out.getBufferSize() != 0) out.clearBuffer();


} finally {


_j spxFactory.releasePageContext(pageContext);




О Initialization of the JSP implicit objects. We see here why they are always available to a JSP by name.
e Static content written to the out object. d Scriptlet content is copied verbatim into our servlet file.

NOTE In JSP1.2, the translation from JSP to Java is not direct but involves an intermediate step whereby the JSP code is translated into an XML representation. This representation is important for reasons such as page validation. Once the page validation is complete, the XML representation is transformed into the Java source.

Note from
listing 2.9 that the servlet emitted by the JSP runtime does not add any real overhead to a hand-coded counterpart. As a result, other than the initial overhead associated with the servlet generation, JSP files share the performance advantages attributed to servlets because the just-in-time (JIT) compiler available with the Java virtual machine (JVM) will compile them into native code. JIT compilers

compile Java on the fly, allowing interpreted Java to execute at speeds comparable to native C++.

2.4 Access models for business/presentation de-coupling

Concurrent with the JSP specification’s release, two JSP “access models” (architectures) were introduced in order to further the crusade to separate presentation from business logic (commonly called decoupling). These access models were mentioned first in version 0.92 of the JSP specification and are known in the industry as Model-1 and Model-2. The JSP access models specify an overall architecture for servlet/JSP web applications, defining how servlets, JSP files, JavaBean components, and back-end systems should cooperate. The architecture enforced by these models provides rules of thumb that ease the conflict between Java business code and HTML (or other) presentations. These models help provide structure to JSP web development, which can occasionally be so flexible that it inadvertently encourages poor programming practices (such as overusing scriptlets). Both models are gaining popularity as architectures for the building of JSP applications, and therefore warrant some discussion of them here. We will first talk about the Model-1 access model, and then explore Model-2.

Скачать в pdf «JSP Tag Libraries»