How to rewrite or generate url like twitter and facebook in java

how to rewrite or create a url like twitter and facebook in java ....

Example: https://www.facebook.com/username , https://www.twitter.com/username

Is there any java-framework for this?

If anyone has ideas on how I can do this, or examples that help me, that would be great!

+4
source share
2 answers

There are many options. Almost every infrastructure can do this. Here are a few options:

  • use UrlRewriteFilter
  • spring -mvc allows you to map a method to /${username}
  • map the servlet to / and process request.getRequestURI() or request.getPathInfo()
+4
source

I would use OCPsoft PrettyFaces or OCPsoft Rewrite for this:

With PrettyFaces :

create WEB-INF / pretty-config.xml

 <url-mapping> <pattern value="/#{username}" /> <view-id value="/profile.jsp" /> </url-mapping> 

This will automatically put the "username" URL value in the request parameter named "username"

With Rewrite :

Here is the same thing using Rewrite, which is a bit more explicit, but also more powerful.

 ConfigurationBuilder.begin() .addRule(Join.path("/{username}").to("/profile.jsp") .where("username").bindsTo(Request.parameter("username"))); 

Hope this helps.

~ Lincoln

0
source

All Articles