views:

609

answers:

1

In PHP/Apache I can get the full url and cut it up into parts like this

URL: mysite.com/friends/enemies-cats/

Then using PHP explode function I can split the URL by the "/" into an array.

Array[0] = 'friends';
Array[1] = 'enemies-cats';

I wonder, is it possible to do the same thing on a Java server. I am hoping the same thing could work on all servers e.g. tomcat, jboss, websphere etc. I would prefer not to use things like urlrewriter if I can avoid it.

Also is it possible to achieve the same thing in ASP?

Realistically, I would like to find the easiest way to convert the URL to an array in each of PHP, JSP, and ASP.

If it is possible, any idea where to start? Any limitations? Any security issues, etc.?

A: 

JSP:

String[] stringArray = url.split("/"); 

PHP: You already have it...

$parts = explode('/', $url);

ASP: I don't know ASP, but here is what google found:

parts = Split(url, "/");
sberry2A
Thanks this really gives me some direction. Just out of interest if its as easy as this, why does java urlrewriter exist because urlrewriter seems a bit overkill for such a simple operation, no?
Ke