Good info Felipe. Sounds like exactly what I was doing, and like you said in your blog, which is why I sent this email to the list, it is bugging me that I know this is NOT a RESTful way to handle this. Like you, I hate the idea of doing something knowing full well it's wrong. A lot of companies seem to work like this.. just to get something out there they are willing to have it done wrong to rush it.
--- On Tue, 3/2/10, Felipe Gaúcho <fgaucho_at_gmail.com> wrote:
From: Felipe Gaúcho <fgaucho_at_gmail.com>
Subject: Re: [Jersey] How do you redirect to a different URL
To: users_at_jersey.dev.java.net
Date: Tuesday, March 2, 2010, 8:55 AM
http://java.dzone.com/articles/pedantic-guide-restful
a good way is to call a URI of a web application and let the application to communicate with the restful service.. this way you have 2 benefits:
1) your customer is already in the application, so no need of redirections in the RESt side
2) the REST continue "pure", because a GET method is idempotent and if you use a link direct in the RESt service it means your confirmation GET will change the state of a resource.. not good :)
On Tue, Mar 2, 2010 at 5:51 PM, Kevin Duffey <andjarnic_at_yahoo.com> wrote:
I have set up a simple email link that does a call to my service to "verify" the email. First off, I am probably doing this wrong.. not sure an email link should be calling a REST URL, but for now that is how I have it set up. I suppose I could call a servlet directly, just thought I'd try with using a URL to my rest service. It may not meet the "RESTFUL" criteria and make my API unrestful.
That said, the first URL that is called as a service is a developer signup page.. the user would fill out some developer info, then submit it. My web page (bundled with my jersey services) uses javascript to make the POST request with the data. That data including email is then used to send out a "verify" email. In it I provide a link to the same service with 2 query params, the email and the generated ID from the previous step (generated by storing
the developer info into the DB and returning the ID that was generated). My goal is to use this ID to match up to the right person in the database, setting its "active" flag to true. All of this works. Clicking on the email calls the service just fine. But, since the email is usually from within a web browser (or an email client that would then launch a web browser), I want to redirect the user back to a "you are verified" html page.
I've set the status to 301, just not sure what method to call to set the URL that the redirect goes back to. Does that have to be the location() method, entity() method, or set as a header somehow?
Thanks.
--
------------------------------------------
Felipe Gaúcho
10+ Java Programmer
CEJUG Senior Advisor