I have written a controller extending from SimpleFormController. I want to check a session variable 'userid' and if that variable is not set, then redirect it to index page, otherwise render the form..
But it gives me following exception when session variable is set and it tries to render "changePwd.jsp"..Here 'updateProfileInfo' is command object.
javax.servlet.ServletException: Neither Errors instance nor plain target object for bean name 'updateProfileInfo' available as request attribute org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758) org.apache.jsp.pages.changePwd_jsp._jspService(changePwd_jsp.java:295)
SimpleFormController offers showForm to handle the case when user is redirect to a new form (usually a GET). For submitting form, onSubmit is used (usually a POST). I read the following in Spring API: protected abstract ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception
Prepare the form model and view, including reference and error data. Can show a configured form page, or generate a form view programmatically.
A typical implementation will call showForm(request, errors, "myView") to prepare the form view for a specific view name, returning the ModelAndView provided there.
For building a custom ModelAndView, call errors.getModel() to populate the ModelAndView model with the command and the Errors instance, under the specified command name, as expected by the "spring:bind" tag. You also need to include the model returned by referenceData.
Note: If you decide to have a "formView" property specifying the view name, consider using SimpleFormController.
Parameters: request - current HTTP request response - current HTTP response errors - validation errors holder Returns: the prepared form view, or null if handled directly
So, if we use the default implementation of showForm of SimpleFormController i guess it will call the view (set in formView property) and populate the request attributes with command and error objects (though they are empty at this time). In your case, you want to use a customized model, so you should follow the API documentation above.