Vaadin URL

How a Vaadin app configure it as one single servlet with the url-pattern /*, be able to access objects like http://localhost:8080/parts/myapplet.jar

The problem I run into is that I want to add an applet, and right now I believe I should create a generic web app to put the applet’s jars

BTW Vaadin is really nice!

Appreciatte your thought on this regards



There are, as usual, several approaches:


  1. Serve static content separately
    That is: not via Vaadin

You can make Tomcat (and others, but YMMV) serve your folder by adding this to your web.xml:


BUT instead you might want to make the pattern /VAADIN/* and put your static stuff PLUS all the stuff from the VAADIN folder in the jar there (or make one /parts and one /VAADIN). This way you’ll serve all the static content w/o hitting the vaadin servlet at all.

FINALLY in a production setup, you should have some other server (not tomcat) serve static content - e.g Apache or Nginx, which are particularly good at serving static content.

2. Use Resources

a) put jar in theme and use ThemeResource
b) put jar among class-files and use ClassResource
c) put jar somewhere else accessible by the servlet and use FileResource.
Oh, and StreamResource can also be used.
The Book about resources

In your case I’d go with 1, though 2 might be more suitable in some other cases.

Best Regards,

You could add something as simple as a JSP page to host the applet, and then your servlet declarations and mapping would look like this:





To put it another way, you don’t need a whole other web application. You can just map a url pattern to another servlet or JSP page. Whatever URL the user goes to, the most specific matching URL pattern wins.