I have the following code in my servlet:
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
public void doIt(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
URL url = new URL("http://some.url.that.works.well.nl/q=hello&ie=nl&cx=hdyehgfyegywjehdkwed:7364du7");
URLConnection conn = url.openConnection();
conn.connect();
BufferedReader br = new BufferedReader(
new InputStreamReader(conn.getInputStream())); // This line is generating the error
String line = "";
PrintWriter pw = response.getWriter();
while((line = br.readLine()) != null) {
pw.println(line);
}
}
running this servlet in tomcat gives me an http 406 error.
What I try to do is from within my servlet call google site search and I would like to parse the receieved (XML) result. (For now I just print te received result). Trying the url in a browser is giving the correct result.
What am I missing here?
Kind regards, Werner