Create a 301 Error with Redirect Info for google

I created and ErrorPage with an error parameter that has a 301 HTTP Error, Everhthing works fine, I just want to to know how to help Google and search engines know where is the new location.

I searched for Vaadin handling still, confused how to insert the new URL for the redirected page. I can put the URL into the error page, and cause an auto redirect after 10 seconds, however, still I think I should insert the 301 error with the new URL, any guidence?

public int setErrorParameter(BeforeEnterEvent event,
            ErrorParameter<CalendarPageMovedException> parameter) {
        System.err.println("params: " + event.getRouteParameters());
        System.err.println("custom Message: " + parameter.getCustomMessage());
        /*    getElement().setLabel("What !!! Could not navigate to '"
                    + event.getLocation().getPath()
                    + "'");//*/
        return HttpServletResponse.SC_MOVED_PERMANENTLY;

    public void beforeEnter(BeforeEnterEvent bee) {
        add(new Html("<div>" + getT("errorPage") + "</div>"));
        //add(new H4(calServ.getT(exception.getExpectedCalendar().getId())));
        add(new CardDateHeader(calServ, calServ.getTodayDate(exception.getExpectedCalendar()),calServ.getSecondary()));

        add(new CalendarAllCard(calServ,calServ.getTodayDate()));
        add(new MyFooter(service, calServ));
        SerializableRunnable r = () -> {
            service.recordVisit(bee.getLocation(), null);



Don’t do that in your application, use the Reverse Proxy in front of your app.

too many pages to process to insert into ingix,
so you mean this 301 page error is useless for google?

The 301 error is required for Google for SEO and updating their index; but it won’t work - except with workarounds… see Status returned by HasErrorParameter#setErrorParameter is ignored. · Issue #13421 · vaadin/flow · GitHub

There is no such thing as too many URLs. You can also work with regex or a pattern in your proxy; something like this should always be handled before your app - nevertheless that it won’t currently work with flow anyway (see issue)

error 200 means sucess.
so the vaadin documentation should be updated, as its useless for those issues.
The workaround is using nginx, any others?
I already have a sitemap that is updated, not sure if google would remove the old pages, or just treat the error pages as official.

Does a simple Redirect from Vaadin to the new pages help with Google?


like call this after 5 seconds?


I’m not a SEO export, so take this with a grain of salt - just an educated guess… if I were Google, I would punish it. So no, I would think it’s bad.

I actually read online that google takes this into consideration to update the index.

Now when I am trying to navigate, I am getting a NullPointerException for VaadinRequest.getCurrent() in the target!

public void afterNavigation(AfterNavigationEvent bee) {
        UI ui = UI.getCurrent();
        System.err.println("after navigation......");
        Thread t = new Thread(() -> {
            try {
                System.err.println("after nav...");
                ui.access(() ->
                        ui.navigate(exception.getClazz(), exception.getRp(), exception.getQr())


                System.err.println("Done Rerouting....");
            } catch (InterruptedException e) {
                // throw new RuntimeException(e);

      //  System.err.println("Trying to bee.reroute: " + exception.getExpectedRoute().getHref());

code in target:

java.lang.NullPointerException: Cannot invoke "com.vaadin.flow.server.VaadinRequest.getHeader(String)" because the return value of "com.vaadin.flow.server.VaadinRequest.getCurrent()" is null
	at com.alhanah.taqueem.webui.views.main.MainView.readDomain( ~[classes/:na]

That’s to be expected if you navigate outside the typical Vaadin lifecircle / thread. You have to manually re-introduce the thread locals… even tho I’ve got a bad feeling with this…

Ugly hack idea. Your Vaadin error handler stores something as an HTTP servlet request attribute, and a servlet filter will check it after the chain is executed and potentially performs the redirect.
The filter should probably wrap the HTTP servlet response to prevent it to be committed too early.

Any clean solution for a redirect after 5 seconds?