RequestType in AbstractApplicationServlet

Question for the dev guys.

AbstractApplicationServlet.getRequestType() is protected but the inner RequestType enum is package-private. Any reason for this? I’d like to be able to use it for safely detecting “noisy” URL paths and do something like:

http://demo.vaadin.com/sampler/12345abc/ → whoa!? → auto redirect to → http://demo.vaadin.com/sampler/

getRequestType() gives me a chance to do that in a reasonably safe way by letting me filter out anything that’s not a RequestType.OTHER type but I have to toString() it since said enum is package-private.

Here’s some simplified code of what I’m doing:

@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
  if (isStandardUserRequest(request) && isFunkyPath(request))
  {
    response.sendRedirect(getCorrectPath(request));
  }
  else
  {
    super.service(request, response);
  }
}

Thanks in advance.

I agree with that having the enum with package visibility while getRequestType() is protected does not make sense. Furthermore, the corresponding enum for portlets already had “protected” visibility.

Changed the visibility of the enum to protected in
ticket 4399
.

Note that if forwarding requests as you plan to do, you should be very careful with what requests are forwarded not to break any functionality.