I have an enterprise application written in JAVA with JSF (using RichFaces 3.3). Currently my URL looks like this:
http://localhost/WebApplication/faces/folder1/page.jsp
Question is how do I mask my url to make it like this:
http://localhost/folder1/page.jps
Basically i want to hide "Application/faces/"
Thanks
Note that the /faces/ is due to the mapping in
web.xml
. this is a standard mapping for JSF, however you could also use extension mapping - i.e..faces
at the end of the URL.For example, in an application I have here this is in the web.xml file:
This is using IceFaces, however it will be similar for you with RichFaces. Yours will probably look like this:
<url-pattern>/faces/*</url-pattern>
. If you change it to have*.faces
as above, your end URL will look like this:http://localhost/WebApplication/folder1/page.faces
If you use that in conjunction with the answer that Peter Hilton gave about deploying as a root web application, your end URL will look something like this:
http://localhost/folder1/page.faces
Which is almost exactly what you wanted.
Yep. We designed PrettyFaces exactly to handle this situation:
PrettyFaces – SEO, Dynamic Parameters, Bookmarks, and Navigation for JSF / JSF2
PrettyFaces lets you rewrite your url. If you prefer something more lightweight, extend NavigationHandler and override handleNavigation, e.g. by calling context.getExternalContext().redirect()
For rewriting URLs within your application you can use UrlRewrite. However, in this case it looks like you want to remove your web application's context path, in which case you have two options:
/
(how is application server-specific)Apache config:
You can also change folder name from faces to jsp for example like this:
And then your url will looks like:
and if you deploy your application to the context path / of application server it will looks like:
it will be hard now to find out that you use JSF for lamers ;-) but a hacker can investigate it by pointing his browser to the url like this
http://localhost/folder1/page.jsp