1

I have a web services written in java using jersey framework when i call it it will return me a xml. But i want to use it in a jsp page for example i have a web service getCoutry() when i call it, it will return me xml as like.

my url is: http://localhost:8080/countries-ws/resources/admin/getCountry?id=1

<conList>
<cid>1</cid>
<iso>AD</iso>
<iso3>AND</iso3>
<name>ANDORRA</name>
<numcode>20</numcode>
<printableName>Andorra</printableName>
</conList>

And i want to use it in a select tag of jsp page. I don't know how to use it please help me guys. Thanks

jmj
  • 225,392
  • 41
  • 383
  • 426
subodh
  • 5,836
  • 12
  • 45
  • 67

1 Answers1

1

Call the webservice from your servlet . set the result in request/session or appropriate scope as attribute and forward this to jsp. on jsp access it using JSTL as simple as that

Update:

URL yahoo = new URL("http://www.yahoo.com/");
BufferedReader in = new BufferedReader(
            new InputStreamReader(
            yahoo.openStream()));

String inputLine;

while ((inputLine = in.readLine()) != null)
    System.out.println(inputLine);

in.close();
jmj
  • 225,392
  • 41
  • 383
  • 426
  • Thanks Jigar, But i don't know how to do it please give me a example i really great need of it – subodh May 10 '11 at 11:40
  • which part you aren't clear about, jsp/servlet stuff or consuming webservices ? – jmj May 10 '11 at 11:41
  • @Jigar Joshi, I have a url of web service that is runing on my tomcat server. and i am confused about how to call it from where i start it and how to call it through servlet. – subodh May 10 '11 at 11:53
  • if you make GET to your URL and it returns this XML ,[you can use HTTPURLConnection to make GET](http://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests) – jmj May 10 '11 at 11:55
  • if possible than plz give me a simple example – subodh May 10 '11 at 12:04