Address Redirection Problem

Test Application com.vaadin.terminal.gwt.server.ApplicationServlet Vaadin application class to start application com.example.test.TestApplication Application widgetset widgetset com.example.test.widgetset.TestWidgetset Test Application /*

When I calling → http://localhost:8080/Test/report/SampleReport.html

this path redirect to http://localhost:8080/Test/ and shows home page. (but Addressbar Shows “http://localhost:8080/Test/report/SampleReport.html” )

can anybody tell me the solution for viewing the SampleReport.html file.


Since you’ve mapped /* to the Vaadin application, any call to http://localhost:8080/Test will load the application. Even http://localhost:8080/Test/this_url_doesnt_match_anything. The most general solution is to move your Vaadin application to another URL, such as /app instead (so that it’s located at http://localhost:8080/Test/app). In this case, your mapping
would look like this:

    <servlet-name>Test Application</servlet-name>

Then any call that doesn’t go to /app will be a normal HTML call. You can even redirect people from / to /app with a simple index.jsp file in the root directory:


The other option is to leave the Vaadin app at /* and give more specific mappings to individual html files. You can do it like this in web.xml:



Of course you’d have to add servlet and mapping elements for each static file that you want to serve, which doesn’t scale well. You could try mapping /report/* to a servlet instead, and write a simple servlet that checks everything after the mapping (e.g., “SampleReport.html”) and forwards to the correct file. I haven’t tried that yet, but in case you’re curious here’s how to do the forward:

    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

        String URLString = // get this from the request however you'd like
            URLString).forward(req, resp);

You’d have to use a forward() rather than redirect so that you don’t run into the same problem you’re already seeing. I haven’t tried this static-file-handling servlet idea before, but I don’t see why it wouldn’t work. I’ll have to tuck that away to try later, heh heh. If you go that route and it works for you, feel free to share. I’ve seen this same question come up a couple times, asked in different ways.


Thanks, Bobby Bissett