0

In my Servlet I use the @MultiPartConfig annotation in combination with the maxFileSize attribute. This works as expected. The only issue I have is that I want to customize the Message (into Dutch). Is there a nice and clean way to achieve this?

My site is just a simple JSP.

Dominik Sandjaja
  • 6,326
  • 6
  • 52
  • 77
Bgvv1983
  • 1,256
  • 1
  • 13
  • 27
  • 1
    Which message do you want to translate? There are no messages directly associated with the `@MultiPartConfig` annotation. – Dominik Sandjaja May 31 '16 at 07:29
  • @DaDaDom Think thats the key of my problem. When I use a File that exceeds the maxFileSize. The jsp is showing: " SRVE8021E: The file being uploaded is too large.". What I'm looking for is a nice and clean way to customize this message. – Bgvv1983 May 31 '16 at 08:15

1 Answers1

0

You can customize message in application level e.g. you can catch exception and throw new exception containing some message or print html in response or forward request to some error page.

protected void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    try {
        Part filePart = req.getPart(FILE_PART_NAME);
    }catch(Exception e) {
        String msg=e.getMessage();
        if(msg!=null) {
            if(msg.contains("SRVE8021E")) {
                throw new IllegalStateException("Etwas auf Deutsch sagen");
            }
        }
Simo Nikula
  • 51
  • 2
  • 3