Im just learning jsp.So it would be helpful if somebody can correct my code.
JSP Code :
String x=request.getParameter("longitude");
String y = request.getParameter("latitude");
String addr1 = "http://ws.geonames.org/findNearby?lat="+y+"&lng="+x;
try
{
myURL = new URL(addr1);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
Document feed = null;
try
{
feed = xmlReader.read(myURL);
System.out.println("Entered");
}
catch (DocumentException e)
{
e.printStackTrace();
}
try
{
String xpathExpression = "/geonames/geoname/";
Node codeISO2= feed.selectSingleNode(xpathExpression+"countryCode ");
Node countryName = feed.selectSingleNode(xpathExpression+"countryName ");
String e=codeISO2.getText();
String f=countryName.getText();
System.out.println(e+f);
System.out.println("The Country Code is "+e+" and the country is "+f);
}
catch(Exception e )
{
System.out.println("Error is "+e);
}
Error is :
org.apache.jasper.JasperException: An exception occurred processing JSP page /countryfind.jsp at line 76
73: String xpathExpression = "/geonames/geoname/";
74:
75:
76: Node codeISO2= feed.selectSingleNode(xpathExpression+"countryCode ");
77: Node countryName = feed.selectSingleNode(xpathExpression+"countryName ");
78: String e=codeISO2.getText();
79: String f=countryName.getText();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handle JspException(JspServletWrapper.java:567)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:456)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet .java:722)
Somebody Please Help.Thanks in advance.