users@jersey.java.net

How do you redirect to a different URL

From: Kevin Duffey <andjarnic_at_yahoo.com>
Date: Tue, 2 Mar 2010 08:51:00 -0800 (PST)

Hey all,

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.