I am integrating with a webservice in my
jsp code.
I built a little class file that gets the results and outputs them to the jsp page.
Unfortunately the output is in XML format and looks like this:
- <xmlRouterResponse>
- <queryAndResponseSet>
- <queryAndResponse>
<query>JJ</query>
<response>JJ1</response>
<response>JJ2</response>
<response>JJ3</response>
</queryAndResponse>
</queryAndResponseSet>
</xmlRouterResponse>
My question is, how can I extract just the response data?
Obviously this requires an XML parser, which I assume is incorporated in Apache?
I've tried hunting google and looking through books, but all the examples I've seen are super duper in depth and don't spend any time or show any examples on how something this simple would be done.
Can this be done from the JSP code? or is this something that is done from within the class/java file?
Any specific help would be fantastic!
My current
Java file looks like this:
package webTest2;
import java.net.*;
import java.io.*;
import java.util.*;
public class webTest2Bean {
String theQuery;
public void setGuess(String guess) {
try{
String linky = "http://centraldictionaryservices.xxx.com:7000/cds/index.cds?alternativeTerms/term/term="+guess;
URL u = new URL(linky);
InputStream is = u.openStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
theQuery = br.readLine();
}
catch (MalformedURLException ex){
System.err.println("catch 1 "+ex);
}
catch(IOException ex){
System.err.println("catch 2 "+ex);
}
}
public String getHint() {
return theQuery;
}
}