users@jersey.java.net

Re: Preprocessing URL HTTP-GET parameter / HTTP-POST data

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 28 Jan 2008 11:23:55 +0100

Hi ks,

If you have a hierarchical relationship in the URI path for a user-based
URIs and sub-resources you can use constructors and sub-locators:

   @Path("{user})
   public class User {
     public User(@PathParam("user") String user) {
       // get user information from DB
     }

    @Path("sub")
    public Object getSubResource() {
       return new SubResource(... pass in user information here ...);
    }
}

This does impose a certain style of development via the use of
per-request life cycle and sub-locators, but you can see how useful
using constructors can be sometimes for keeping things DRYer.

I suspect using an IoC framework it may be possible to avoid the passing
of information to constructors of sub-resources.

Another solution is to have all user-based resources extend a common
abstract class the constructor of which gets user the required information.

I am definitely interested in alternative ideas/ways of managing this.

Paul.
KSChan wrote:
> Hi,
>
> I would like to know is there any ways to preprocess the data when
> invoking the web service?
>
> For example, if I have a web service to obtain USER ID from DB with a
> LOGIN NAME and PASSWORD; could I preprocess the data before the
> invocation of the method defined in the resource? The preprocessing is
> aimed as preventing SQL injection for "all" resource so that I won't
> need to process the data every time.
>
> ks.
>
> --
> I, have a dream. I want to make my dream come true.
>
> http://mr.kschan.googlepages.com

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109