Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

TUTORIALVaadin lets you build secure, UX-first PWAs entirely in Java.
Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Calling javascript synchronously by Enver Haase, 2 weeks ago
Jetty embedded with Vaadin. How to add static content folder?
Good day.
I have a Vaadin 7 started on Jetty embedded. It works good.
Now i need to load some static content from folder (HTML,JS) inside JAR.
How can i do it?
Already works code with only Vaadin:
Server server = new Server();
/**
* ServletContextHandler
*/
ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
servletContextHandler.setContextPath("/");
/**
* ContextHandler for Vaadin
*/
ServletHolder servletHolderVaadin = new ServletHolder(new VaadinServlet());
servletContextHandler.addServlet(servletHolderVaadin, "/*");
servletContextHandler.setInitParameter("ui", VaadinUI.class.getCanonicalName());
server.setHandler(servletContextHandler);
Last updated on
Resolved.
ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
servletContextHandler.setContextPath("/");
inetAccessHandler2.setHandler(servletContextHandler);
ServletHolder holderHome = new ServletHolder("static-home", DefaultServlet.class);
String pwdPath = System.getProperty("user.dir");
holderHome.setInitParameter("resourceBase", pwdPath + "/_phone");
holderHome.setInitParameter("dirAllowed","true");
holderHome.setInitParameter("pathInfoOnly","true");
servletContextHandler.addServlet(holderHome, "/_phone/*");
ServletHolder servletHolderVaadin = new ServletHolder(new VaadinServlet());
servletContextHandler.setInitParameter("ui", VaadinUI.class.getCanonicalName());
servletContextHandler.addServlet(servletHolderVaadin, "/*");
Last updated on
You cannot reply to this thread.