Question

I am looking for a java library/class to parse clean URL's and get all the properties like query, port, host , domain, subdomain etc. Essentially most of the functionality that java.net.URI does but even for clean URLs. I am guessing since this is a pretty common requirement, there might be some libraries already built to handle this. Help?

Was it helpful?

Solution

java.net.URL class has methods getHost(), getPort(), getQuery(), getPath().

You can also look at URI class, it's more preferred to use it.

OTHER TIPS

The standard Java Url classes do not have functionality to parse request parameters. There is a utility class in Commons HTTP Client which has a useful method to do this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top