wood burning stoves 2.0*
The moose likes Servlets and the fly likes Tips to write friendly URLs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Tips to write friendly URLs" Watch "Tips to write friendly URLs" New topic
Author

Tips to write friendly URLs

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

Hey,
I am trying to write a Friendly URLs by hand:
/servlet/2010/11/27
/servlet/year/2010/month/11/day/27
How to access request parameters this way?
I'm doing it right now via RegExp but is there a better way?
Thanks.
dave hopkins
Greenhorn

Joined: Oct 27, 2006
Posts: 25
There's more to REST than just matching params dude. Forget code just for the minute and read up on the principles first.

Here's a really good article

http://www.peej.co.uk/articles/restfully-delicious.html
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

What you are describing is not RESTful, it's called "friendly URLs".

So what are you really asking? Do you want to create a RESTful web service? Or do you just want to be able to specify parameters in the URL rather than in a query string?

If the latter, you can grab the string using getPathInfo() and parsing it yourself.


P.S. The FrontMan 2 beta does this for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

Yes, I mean friendly URLs not RESTful, sorry I forgot about that.
Actually that is what I'm doing, parse the string of getPathInfo().
I will correct my post subject.
Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

Can you not just use String.split()?
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

Bear Bibeault wrote:Can you not just use String.split()?

Even better
Thanks.
Jagdeep Sharma
Ranch Hand

Joined: May 24, 2010
Posts: 121

John Todd wrote:
Bear Bibeault wrote:Can you not just use String.split()?

Even better
Thanks.


Hey People,

I found myself very new to this topic. Can you people give some difference between RESTful urls and user friendly urls.

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

REST
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tips to write friendly URLs
 
Similar Threads
SSL and Tomcat problems - ClassNotFoundException: TLS
CMS - Approach to handle requests using directory names
Jax-ws client deploy stucked
FIPS compliant Tomcat using JSSE
JForum nice urls (as on Java Ranch)