Reputation: 151
I want to pass a parameter 'A1B2C3' to a GWT application based on Google App Engine. I do it like www.example.com/index.html?key=A1B2C3. Although it's working, I'd like to use pretty URLs. Is it possible to do URL rewriting on Google App Engine? I couldn't find out how.
www.example.com/A1B2C3
instead of
www.example.com/index.html?key=A1B2C3
I'm using Google App Engine and GWT. All in Java.
Upvotes: 13
Views: 5477
Reputation: 441
Try UrlRewriteFilter: http://tuckey.org/urlrewrite/ (or github repo) it is a plain ol' Java EE filter, so it should work.
Upvotes: 3
Reputation: 3191
I would probably use PrettyFaces, http://ocpsoft.com/prettyfaces/ which allows you to do URL-mappings directly on top of an existing application.
You just configure something like this in the pretty-config.xml file:
<url-mapping>
<pattern value="/my/pretty/url" />
<view-id value="/my/existing/url" />
</url-mapping>
Or if you want to rewrite parameters, you can do this:
<url-mapping>
<pattern value="/my/pretty/url/#{param}" />
<view-id value="/my/existing/url" />
</url-mapping>
And this means that any urls (inbound) now become:
/my/pretty/url/value -> /my/existing/url?param=value
And outbound your URLs will look like this in HTML pages and in redirects:
/my/existing/url?param=value -> /my/pretty/url/value
So it's easy to add on to your current apps.
Upvotes: 1
Reputation: 813
This is the best approach I found so far for implementing URL rewrite GAE Python
Upvotes: 0
Reputation: 39395
Here is another project that I think may really help you:
It's called restful-gwt... it's pretty slick too: http://code.google.com/p/restful-gwt/
Good luck!
Upvotes: 0
Reputation: 39395
Save yourself some time and use Restlet. You can do exactly this and I've done this in two different projects. It's quite straight forward. If you need some help, let me know.
Upvotes: 1
Reputation: 1625
This is a cool question. I figured out how to do it for python as well.
app.yaml:
- url: /test/(.*)
script: test.py \1
test.py:
#!/usr/bin/env python
import sys
def main():
for arg in sys.argv:
print arg
if __name__ == '__main__':
main()
Upvotes: 7
Reputation: 96746
You need to configure the application (see here). In other words, you need to "wire" the patterns you want.
From the manual, an example:
<servlet-mapping>
<servlet-name>redteam</servlet-name>
<url-pattern>/red/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>blueteam</servlet-name>
<url-pattern>/blue/*</url-pattern>
</servlet-mapping>
Upvotes: 6