Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tips to write friendly URLs

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64830
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64830
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you not just use String.split()?
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Can you not just use String.split()?

Even better
Thanks.
 
Jagdeep Sharma
Ranch Hand
Posts: 121
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64830
86
IntelliJ IDE Java jQuery Mac Mac OS X
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic