views:

33

answers:

1

Hi all,

I am developing a JEE project (used EJB3, JSF and maven) run on jboss 4.2GA app. server. My problem is I want to rewrite my URLs while passing param values between pages. In other words, for instance, when user clicks a submit button, some of the params are added to the end of url, you know; however I want it to be more clear like: ../testApp/testPage/12 instead of ../testApp/testPage.jsf?id=..

I hope I could clearly explain my need.

Any help would be appreciated, thanks a lot Baris

+1  A: 

The most used solution with Java is URLRewrite Filter . The newer versions also have syntax that looks very similar to the very wide used and known "mod_rewrite" one (since this is what most apache httpd based servers use).

You can find documentation and examples there, and many of the solutions on the google group too - since what you mention in your question is a very a common requirement for many applications.

Also please note that you might need both inbound and outbound rules for rewriting too (you'll find examples there), as URLRewrite Filter can't automatically calculate "the inverse" of a rewrite expression.

For rewriting solutions in general, if a user is not quite fluent with regular expressions, than it would make sense to install in the favorite IDE some sort of RegExp plug-in to try those rewrite expressions first (it saved me allot of time in the past :) ).

A. Ionescu
Many many thanks for your reply,BTW I want it to be sure that is urlrewrite filter for not only apache, but also for jboss as well? I am confused about that. I know Jboss is based on Apache for some of funcitonalities, however I am not clear on these, that's why I wanted to ask.Best wishes
Bariscan
@Bariscan: I suppose I wasn't very precise. When I mean Apache, I mean Apache HTTPD Server - the native (not Java based) popular server. JBoss on the other side is based on Apache.org Java projects (that's something else). This is a Servlet Filter I'm talking about, so when configured as described, it should work with Java applications. You can of course put a Native server in front of you Java application and than you can put there your rewrite rules, but that seems more complicated to me.
A. Ionescu
Bariscan
I'm not sure what you try to achieve, but using English characters in an URL is a very good idea (it doesn't matter if the content is foreign, URLs should really have an English like form). The server code should generate and use only nice and valid English URLs, this way there's no problem. I'm not sure though if you can avoid transforming those characters since this is how browsers behave.
A. Ionescu