Request Handler is not working

HI,

I want to open a new window when specific url is entered.I used request handler to do this but it is not working.Window is not opening.Below is my code

public class SampleappUI extends UI {

 public static final String URL = "GSAWindow";

    private final RequestHandler requestHandler = new RequestHandler() {
        

		@Override
		public boolean handleRequest(VaadinSession session,
				VaadinRequest request, VaadinResponse response)
				throws IOException {
			// TODO Auto-generated method stub
			if (("/" + URL).equals(request.getPathInfo())) {
               
                Window w=new Window("Sample");
                Label label=new Label("Welcome User");
                w.setContent(label);
               ((SampleappUI)session.getAttribute("UI")).addWindow(w);
                return true;
            }
            // If the URL did not match our image URL, let the other request
            // handlers handle it
            return false;			}
    };

    @Override
    public void init(VaadinRequest request) {
        
        getSession().setAttribute("UI", this);
        getSession().addRequestHandler(requestHandler);
        Label label=new Label("Helloo User!!!!!!!!!Request Handler sample");
        setContent(label);
    }

    @Override
    public void detach() {
        super.detach();

        // Clean up
        getSession().removeRequestHandler(requestHandler);
    }
}

Can any one tell me what’s wrong in the code

can anyone help me on this

RequestHandlers work on a bit lower level than what’s appropriate here. Because a new UI is created for each browser window/tab the user opens, you can simply do the window opening in your UI.init() method. Adding a RequestHandler in UI.init() is usually too late - the request that opened the UI is already being handled - plus, you end up adding a new handler to the session each time a new UI is created. Also, as there may be multiple UIs per user session, it does not usually make sense to store a UI reference to the session - it will end up pointing to the UI that was last created, not necessarily the one the user is currently interacting with.

@Override
public void init(VaadinRequest request) {
  if (("/" + URL).equals(request.getPathInfo())) {
    Window w=new Window("Sample");
    Label label=new Label("Welcome User");
    w.setContent(label);
    addWindow(w);
  }
  Label label=new Label("Helloo User!!!!!!!!!Request Handler sample");
  setContent(label);
}