Hi,

I have question for which I'm sure there must a simple solution - I
just haven't found it yet and so I hope someone can give me a hint.

I'm writing a small GWT application where there's only one static page
(index.html) and many dynamic pages which I'll create on the fly from
data in a database given a key. What I want to achieve is this:

http://www.domain.com    should serve the main page (index.html)

http://www.domain.com/xyz    should serve page xyz, where xyz is just
any key for which I want to do a look up in a database. If there is an
item associated with key xyz, I'll load that, otherwise I'll show a
404 error page.

I was trying to modify the web.xml file accordingly but I couldn't
make it work. I could only make it work with an url-pattern if the key
is after another /, for example www.domain.com/search/xyz. However,
I'd like to have xyz directly following the root / (www.domain.com/
xyz).

Something like

        <servlet-mapping>
                <servlet-name>main</servlet-name>
                <url-pattern>/</url-pattern>
        </servlet-mapping>

doesn't seem to work as I don't know how to address the main page
index.html (as it's not an actual servlet) which will then load my
main GWT module.

I could make it work with a bad work around (see below): Redirecting a
404 exception to index.html and then doing the look up in the main
entry point, but I'm sure that's not the best practice, also for SEO
purposes.

Can anyone give me a hint on how to configure the web.xml with GWT for
my purpose?

Thanks a lot.

Mike

----

Work-around 404:

Web.xml
-------------

<web-app>

  <error-page>
        <exception-type>404</exception-type>
        <location>/index.html</location>
  </error-page>

  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>

</web-app>


index.html --> Main Entry point --> onModuleLoad():
-------------

String path = Window.Location.getPath();

if (path == null || path.length() == 0 || path.equalsIgnoreCase("/")
|| path.equalsIgnoreCase("/index.html")) {
                        // load main page
} else {
        lookup(path.substring(1)); // that's key xyz
}
-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.


Reply via email to