Usage with Grails should be straightforward, here is an example demonstrating it working. Here's an example page and the web.xml below it
<!DOCTYPE html> <html> <head> <meta name="layout" content="main"/> <title>Welcome to Grails</title> <style type="text/css" media="screen"> #status { background-color: #eee; border: .2em solid #fff; margin: 2em 2em 1em; padding: 1em; width: 12em; float: left; -moz-box-shadow: 0px 0px 1.25em #ccc; -webkit-box-shadow: 0px 0px 1.25em #ccc; box-shadow: 0px 0px 1.25em #ccc; -moz-border-radius: 0.6em; -webkit-border-radius: 0.6em; border-radius: 0.6em; } .ie6 #status { display: inline; /* float double margin fix http://www.positioniseverything.net/explorer/doubled-margin.html */ } #status ul { font-size: 0.9em; list-style-type: none; margin-bottom: 0.6em; padding: 0; } #status li { line-height: 1.3; } #status h1 { text-transform: uppercase; font-size: 1.1em; margin: 0 0 0.3em; } #page-body { margin: 2em 1em 1.25em 18em; } h2 { margin-top: 1em; margin-bottom: 0.3em; font-size: 1em; } p { line-height: 1.5; margin: 0.25em 0; } #controller-list ul { list-style-position: inside; } #controller-list li { line-height: 1.3; list-style-position: inside; margin: 0.25em 0; } @media screen and (max-width: 480px) { #status { display: none; } #page-body { margin: 0 1em 1em; } #page-body h1 { margin-top: 0; } } </style> <script src="a.rapidspellweb?t=r&n=RapidSpell-AYT.js"></script> </head> <body> <a href="#page-body" class="skip"><g:message code="default.link.skip.label" default="Skip to content…"/></a> <div id="status" role="complementary"> <h1>Application Status</h1> <ul> <li>App version: <g:meta name="app.version"/></li> <li>Grails version: <g:meta name="app.grails.version"/></li> <li>Groovy version: ${GroovySystem.getVersion()}</li> <li>JVM version: ${System.getProperty('java.version')}</li> <li>Reloading active: ${grails.util.Environment.reloadingAgentEnabled}</li> <li>Controllers: ${grailsApplication.controllerClasses.size()}</li> <li>Domains: ${grailsApplication.domainClasses.size()}</li> <li>Services: ${grailsApplication.serviceClasses.size()}</li> <li>Tag Libraries: ${grailsApplication.tagLibClasses.size()}</li> </ul> <h1>Installed Plugins</h1> <ul> <g:each var="plugin" in="${applicationContext.getBean('pluginManager').allPlugins}"> <li>${plugin.name} - ${plugin.version}</li> </g:each> </ul> </div> <div id="page-body" role="main"> <h1>Welcome to Grails</h1> <p>Congratulations, you have successfully started your first Grails application! At the moment this is the default page, feel free to modify it to either redirect to a controller or display whatever content you may choose. Below is a list of controllers that are currently deployed in this application, click on each to execute its default action:</p> <textarea id='ta1'>some textt</textarea> <div id="controller-list" role="navigation"> <h2>Available Controllers:</h2> <ul> <g:each var="c" in="${grailsApplication.controllerClasses.sort { it.fullName } }"> <li class="controller"><g:link controller="${c.logicalPropertyName}">${c.fullName}</g:link></li> </g:each> </ul> </div> </div> </body> </html>
And the web.xml (which was created by doing "grails install-templates" http://stackoverflow.com/questions/9924616/how-do-i-use-a-servlet-in-my-grails-app)
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" metadata-complete="true" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name>/@grails.project.key@</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <context-param> <param-name>webAppRootKey</param-name> <param-value>@grails.project.key@</param-value> </context-param> <context-param> <param-name>RapidSpellUserDictionaryLegacyMode</param-name> <param-value>true</param-value> </context-param> <filter> <filter-name>sitemesh</filter-name> <filter-class>org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter</filter-class> </filter> <filter> <filter-name>charEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <init-param> <param-name>targetBeanName</param-name> <param-value>characterEncodingFilter</param-value> </init-param> <init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>charEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>sitemesh</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>ERROR</dispatcher> </filter-mapping> <listener> <listener-class>org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener</listener-class> </listener> <!-- Grails dispatcher servlet --> <servlet> <servlet-name>grails</servlet-name> <servlet-class>org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- The Groovy Server Pages servlet --> <servlet> <servlet-name>gsp</servlet-name> <servlet-class>org.codehaus.groovy.grails.web.pages.GroovyPagesServlet</servlet-class> </servlet> <servlet> <servlet-name>RapidSpellWebHandlerServlet</servlet-name> <description>Handles requests for RapidSpell Web</description> <servlet-class>com.keyoti.rapidSpell.web.ControlServlet</servlet-class> <init-param> <param-name>licenseKey</param-name> <param-value></param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>RapidSpellWebHandlerServlet</servlet-name> <url-pattern>*.rapidspellweb</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>gsp</servlet-name> <url-pattern>*.gsp</url-pattern> </servlet-mapping> <session-config> <!-- 30 minutes --> <session-timeout>30</session-timeout> </session-config> <welcome-file-list> <!-- The order of the welcome pages is important. JBoss deployment will break if index.gsp is first in the list. --> <welcome-file>index.html</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>index.gsp</welcome-file> </welcome-file-list> </web-app> |