Java / Servlets

jasty.web source code is available on GitHub

To make jasty.web work in your project you should go through the following steps:

  • create your own form engine servlet version

    Inherit from FormEngineServlet, override createFormEngineFactory method and configure your custom FormEngine. Example below shows basic configuration for JSP rendering. You can create your own implementations for FormPersister, MethodInvoker, ViewRenderer and (very unlikely) ParameterProvider.

                    public class JspFormEngineServlet
                        extends FormEngineServlet {
                        protected FormEngineFactory createFormEngineFactory(ServletConfig config) {
                            return new JspFormEngineFactory();
                    class JspFormEngineFactory extends FormEngineFactory {
                        FormPersister formPersister = new ClientSideFormPersister();
                        MethodInvoker methodInvoker = new SimpleExceptionHandler(new DefaultMethodInvoker());
                        public FormEngine getFormEngine(ServletRequest request, ServletResponse response) {
                            ParameterProvider parameterProvider = new RequestParameterProvider(request);
                            ViewRenderer viewRenderer = new JspViewRenderer(request, response);
                            return new FormEngine(parameterProvider, viewRenderer, formPersister, methodInvoker);
  • configure your form engine servlet in web.xml


    This snippet configures Form Engine to be available under /formEngine.

  • reference tag libraries in web.xml

    This example references standard tags from the jasty.jsp-module. But you can create and reference your own tag libraries.

  • create entry page

    This is the only page of your single-page application. It references all necessary JS-libraries, configures the form engine servlet URI and places application portlet on the page (formViewer-tag).

                        <%@ taglib prefix="jst" uri="" %>
                            <title>Guess a number</title>
                            <script src="resources/jquery-1.7.min.js" type="text/javascript"></script>
                            <script src="resources/jquery.form.js" type="text/javascript"></script>
                            <script src="resources/jasty-core.js" type="text/javascript"></script>
                            <script src="resources/jasty-components.js" type="text/javascript"></script>
                                jasty.settings.formEngineUrl = "formEngine";
                            <jst:formViewer id="guessnum" entryPointClass="guessnumber.MainForm" />

    The application is then running inside the specified location.