Java Reference
In-Depth Information
Figure 10.1. Guide to the technologies in this chapter. Spring provides mock objects for testing that are also used
in Grails. Using plugins and some configuration, Gradle builds can do integration testing of web applications.
The ServletCategory class makes session, request, and other objects easier to use. Groovlets are a quick way
to build simple applications. Finally, the HTTPBuilder project provides a programmatic web client, and Grails
applications use Groovy DSLs and elegant metaprogramming to combine Spring and Hibernate in a standard
convention-over-configuration framework.
10.1. Groovy servlets and ServletCategory
Groovydoesn'taddalottobasicservletdevelopment,butthestandardlibrarydoesprovide
a category class that illustrates what Groovy's metaprogramming can do. The following
listing shows a trivial servlet, HelloGroovyServlet.groovy , part of a web applica-
tion implemented in Groovy.
Listing 10.1. A simple servlet implemented in Groovy
class HelloGroovyServlet extends HttpServlet {
void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.writer.print 'Hello from a Groovy Servlet!'
}
}
 
Search WWH ::




Custom Search