users@jersey.java.net

[Jersey] Re: Javascript call a Jersey method

From: mahan_h <mahorad_at_gmail.com>
Date: Fri, 11 Mar 2011 03:17:45 -0800 (PST)

Pavel Bucek-2 wrote:
>
> Hello,
> just like regular http request, see for example [1] or javascript
> frameworks offer simplified and more sophisticated way how to do this
> (see [2]).
> Regards,
> Pavel
> [1]
> http://java.net/projects/jersey/sources/svn/content/trunk/jersey/samples/jersey-ejb/src/main/webapp/index.html?rev=4700
> [2] http://en.wikipedia.org/wiki/Comparison_of_JavaScript_frameworks
>

Thanks, finally managed to contact with my resource but seems like I cannot
send any parameters along the path.

I try to reach my service in JS as follows:
        xmlHttp.open("GET", "/restprj/services/search/java?slot=0", true);
        xmlHttp.send(null);

and in my resource, I try to access my parameter as:
        @Produces("text/html")
        @GET
        @Path("{phrase}")
        public String searchPhrase(@PathParam("phrase") String keyword,
@Context UriInfo ui) {
                
                MultivaluedMap&lt;String, String&gt; queryParams1 =
ui.getPathParameters();
                System.out.println("slot param (path): " +
queryParams1.getFirst("slot"));

                MultivaluedMap&lt;String, String&gt; queryParams =
ui.getQueryParameters();
                System.out.println("slot param (query): " +
queryParams.getFirst("slot"));
                ....
        }

and the output is:

slot param (path): null
slot param (query): null

I wonder how should I send additional parameters to my resource.!!!
any hint regarding that??
Regards

--
View this message in context: http://jersey.576304.n2.nabble.com/Javascript-call-a-Jersey-method-tp6159359p6161045.html
Sent from the Jersey mailing list archive at Nabble.com.