Tissen wrote:
> Could anybody suggest a way to handle this exception (not using
> commong Error page)?
I think some new stuff is coming for this in 1.5, but for 1.4 it's still
fairly easy to do. See
http://stripes.sourceforge.net/docs/current/javadoc/net/sourceforge/stripes/exception/DelegatingExceptionHandler.htmlYou'll need this in your web.xml:
<init-param>
<description>Stripes exception handler</description>
<param-name>ExceptionHandler.Class</param-name>
<param-value>net.sourceforge.stripes.exception.DelegatingExceptionHandler</param-value>
</init-param>
<init-param>
<description>Stripes exception resolver filter</description>
<param-name>DelegatingExceptionHandler.UrlFilters</param-name>
<param-value>WEB-INF/classes</param-value>
</init-param>
The I have a class like this:
public class UploadExceptionHandler implements AutoExceptionHandler {
/**
* Handle a file upload exception.
* @param e the exception to handle.
* @param request the upload request.
* @param response the upload response.
* @return a redirect to the error page.
*/
public Resolution handle(FileUploadLimitExceededException e,
HttpServletRequest request, HttpServletResponse response) {
RedirectResolution r =
new RedirectResolution("/error/upload.jsp");
r.addParameter("posted", e.getPosted() / 1048576.0);
r.addParameter("maximum", e.getMaximum() / 1048576.0);
return r;
}
}
And a JSP like this:
<h2>File Upload Error</h2>
<p class="error">
You attempted to upload a file that was
<fmt:formatNumber value="${param.posted}"
maxFractionDigits="1"/>Mb
in size, the maximum allowed file size is
<fmt:formatNumber value="${param.maximum}"
maxFractionDigits="1"/>Mb.
Please only upload valid files.
</p>
--
Alan Burlison
--
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users