Results 1 to 6 of 6
  1. #1
    ur2cdanger is offline Member
    Join Date
    Oct 2011
    Posts
    6
    Rep Power
    0

    Default Whats wrong with my jsp code?

    Im getting an error message when I run this JSP Code.Can anybody clear me about this?

    Code :

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.net.*" %>
    <%@ page import="java.util.List" %>
    <%@ page import="org.dom4j.io.SAXReader" %>
    <%@ page import="org.dom4j.Document" %>
    <%@ page import="org.dom4j.DocumentException" %>
    <%@ page import="org.dom4j.Node" %>


    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <FORM METHOD=GET ACTION="findcountry.jsp">
    City ? <INPUT TYPE=TEXT NAME=City SIZE=20>
    Longitude ? <INPUT TYPE=TEXT NAME=longitude SIZE=20>
    Latitude ? <INPUT TYPE=TEXT NAME=latitude SIZE=20>
    <P><INPUT TYPE=SUBMIT>

    <h1><% out.println("The Given Longitude is "+request.getParameter("longitude")); %></h1>
    <h1><% out.println("The Given Latitude is "+request.getParameter("latitude")); %></h1>
    <h1><% out.println("The Given City is "+request.getParameter("City")); %></h1>

    <%try
    {
    URL myURL = null;
    SAXReader xmlReader = new SAXReader();
    Connection conn = null;
    String userName="root";
    String password = "manutd";
    String url = "jdbc:mysql://localhost/surya";
    //out.println(userName+password);
    Class.forName ("com.mysql.jdbc.Driver").newInstance ();
    conn = DriverManager.getConnection (url, userName, password);
    Statement stmt=conn.createStatement();
    String country=null;
    String x=request.getParameter("longitude");
    String y = request.getParameter("latitude");
    float longi = Float.valueOf(x.trim()).floatValue();
    float lati = Float.valueOf(y.trim()).floatValue();
    String query = "select * from country_details;";
    //out.println(query);
    String addr = "http://api.geonames.org/neighbourhood?lat=40.78&lng=-73.96&username=demo";
    System.out.println(addr);

    try
    {
    myURL = new URL(addr);

    }
    catch (MalformedURLException e)
    {
    e.printStackTrace();
    }


    Document feed = null;
    try
    {
    feed = xmlReader.read(myURL);
    System.out.println("Entered");
    }
    catch (DocumentException e)
    {
    System.out.println("The error here is "+e);
    }

    try
    {
    String xpathExpression = "/geonames/neighbourhood/";
    System.out.println(xpathExpression);
    List<? extends Node> nodes = feed.selectNodes(xpathExpression); /*The Error is here in this line 77 */
    Statement s = null;

    for (Node node : nodes)
    {
    Node codeISO2= node.selectSingleNode("countryCode");
    Node city = node.selectSingleNode("city");
    String e=codeISO2.getText();
    String f=city.getText();
    %><h1> The Country Code is <% out.println(e); %> and the city is <% out.println(f); %></h1>
    <%
    }
    }
    catch(Exception e )
    {
    System.out.println("Error is "+e);
    }

    }

    catch(Exception e)
    {
    out.println(e);
    }
    %>

    </FORM>

    </body>
    </html>


    Error is :

    SEVERE: Servlet.service() for servlet [jsp] in context with path [/WebServices] threw exception [An exception occurred processing JSP page /findcountry.jsp at line 77



    Please help me to resolve the error

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: Whats wrong with my jsp code?

    It should tell you what the exception was.
    Which line is line 77?
    Looks like it had problems turning the page into a Java class.

  3. #3
    ur2cdanger is offline Member
    Join Date
    Oct 2011
    Posts
    6
    Rep Power
    0

    Default Re: Whats wrong with my jsp code?

    Thank you Tolls for replying.

    List<? extends Node> nodes = feed.selectNodes(xpathExpression); /*The Error is here in this line 77 */

    The error is in this line.Can you say why is this error caused?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: Whats wrong with my jsp code?

    List<Node> ...
    not <? extends Node>.

  5. #5
    ur2cdanger is offline Member
    Join Date
    Oct 2011
    Posts
    6
    Rep Power
    0

    Default Re: Whats wrong with my jsp code?

    But changing that gives error

    Type mismatch: cannot convert from List<capture#2-of ? extends Node> to List<Node> countryfind.jsp /WebServices/WebContent line 77 JSP Problem

  6. #6
    gary_bu is offline Member
    Join Date
    Oct 2011
    Posts
    1
    Rep Power
    0

    Default Re: Whats wrong with my jsp code?

    cant't convert from List<? extends Node> to List<Node>

Similar Threads

  1. whats wrong with this code?
    By Petee in forum New To Java
    Replies: 8
    Last Post: 09-30-2011, 04:39 PM
  2. whats wrong with my code
    By naved in forum New To Java
    Replies: 5
    Last Post: 07-15-2011, 02:06 AM
  3. Whats wrong with my code
    By zit1343 in forum New To Java
    Replies: 9
    Last Post: 01-24-2011, 01:06 AM
  4. whats wrong with this code
    By hamzeeco in forum Java Applets
    Replies: 1
    Last Post: 12-31-2010, 02:19 PM
  5. Whats wrong with my code???
    By Soda in forum New To Java
    Replies: 2
    Last Post: 12-06-2007, 12:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •