users@jersey.java.net

Re: [Jersey] How do you redirect to a different URL

From: Felipe Gaścho <fgaucho_at_gmail.com>
Date: Tue, 2 Mar 2010 17:55:54 +0100

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:

> 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.
>
>
>


-- 
------------------------------------------
  Felipe Gaścho
  10+ Java Programmer
  CEJUG Senior Advisor