users@jersey.java.net

[Jersey] Re: Javascript call a Jersey method

From: jmilkiewicz <jmilkiewicz_at_gmail.com>
Date: Mon, 21 Mar 2011 04:29:35 -0700 (PDT)

Hi

I recommend using www.angularjs.org/
I use it with Jersey and works as a charm...

regards miluch

2011/3/21 Jakub Podlesak-2 [via Jersey]
<ml-node+6191886-1439867117-315806_at_n2.nabble.com>:
> Right, particularly you have to change your method signature as follows:
>
> @Produces("text/html")
> @GET
> @Path("{phrase}")
> public String searchPhrase(@PathParam("phrase") String keyword,
> @QueryParam("slot") String slot)
>
> ~Jakub
>
>
>
> On 03/11/2011 12:54 PM, Leonardo wrote:
>> You could use @QueryParam
>>
>> 2011/3/11 mahan_h<[hidden email]>:
>>> 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 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) {
>>>                 StringBuffer buff = new StringBuffer();
>>>                 Twitter twitter = new TwitterFactory().getInstance();
>>>                 List tweets = new ArrayList();
>>>
>>>                 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??
>>> Thanx
>>>
>>> --
>>> View this message in context:
>>> http://jersey.576304.n2.nabble.com/Javascript-call-a-Jersey-method-tp6159359p6161029.html
>>> Sent from the Jersey mailing list archive at Nabble.com.
>>>
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://jersey.576304.n2.nabble.com/Javascript-call-a-Jersey-method-tp6159359p6191886.html
> To start a new topic under Jersey, email
> ml-node+576304-221093730-315806_at_n2.nabble.com
> To unsubscribe from Jersey, click here.


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