How register a component that initializes WebDispatcherServlet?

Hi,

I need use in my project HttpServletRequest. I have followed the documentation
Registering DispatcherServlet from Application Component - CUBA Platform. Developer’s Manual

I have created the WebDispatcherServlet class in web/src, but I am not sure how register the component that initializes the WebDispatcherServlet. I would appreciate if the steps to register.I use v7.2.13.
Thanks

Hi,
That section of the documentation is necessary only for those who need to register a servlet from the application component. Unless you are developing an application component (add-on) - you don’t need it.
What are your actual requirements?

Hi,
I need to get the servername from the url before loading the data from the screen. For this I need to use HttpServletRequest

HttpServletRequest httpServletRequest;
@Subscribe
public void onBeforeShow(BeforeShowEvent event) {
    String domain = httpServletRequest.getServerName();
    //some logic business  
}

Thanks

When working in the GUI screens, you can use the com.haulmont.cuba.web.sys.RequestContext class.
Call RequestContext.get().getRequest() to obtain current HttpServletRequest.

1 Like

Thank you. Work perfect!