Discussions

Web tier: servlets, JSP, Web frameworks: error passing url variable

  1. error passing url variable (3 messages)

    i am trying to send a URL variable and keep getting an error. I'll send the code samples along.

    // error msg
    org.apache.jasper.JasperException: Unable to compile class for JSPC:\bin\tomcat\work\www.smweb.cc_8080\_0002fsourcebook_0002fmaster_0002fip_0005fedit_0002ejspip_0005fedit_jsp_1.java:99: Incompatible type for declaration. Can't convert java.lang.String to int.
                     int IPNumber = "";
    //i'm not sure why it needs a string. ipnumber is a number.
                         
    //input page
    a href="ip_edit.jps?IPNumber=<%= IPNumber %>

    //detail page
    <% int IPNumber = "";
       String IPName = "";
       String Address = "";
       String Address1 = "";
       String Address2 = "";
       String City = "";
       String StateRegion = "";
       String Postcode = "";
       String Phone = "";
       String Fax = "";
       String URL_link = "";
       String Email = "";
       String Profile = "";
       String USRegion = "";
       String CountryName = "";
       ResultSet rset = null;

        String sql =
          "SELECT " +
    "IPNumber, IPName, Address, Address1, Address2, City, StateRegion, Postcode, " +
    "Phone, Fax, URL_link, " +
    "Email, Profile, USRegion, CountryName " +
          "FROM " +
            "IPs " +
    "WHERE " +
    "IPNumber = " +
    "'" + request.getParameter("IPNumber") + "'";

        try {
          rset = stmt.executeQuery (sql);
        }
        catch (SQLException e) {
          out.println (e);
    return;
        }

        while (rset.next ())
        {
          IPNumber = rset.getInt ("IPNumber");
    IPName = rset.getString ("IPName");
          Address = rset.getString ("Address");
          Address1 = rset.getString ("Address1");
    Address2 = rset.getString ("Address2");
    City = rset.getString ("City");
    StateRegion = rset.getString ("StateRegion");
    Postcode = rset.getString ("Postcode");
    Phone = rset.getString ("Phone");
    Fax = rset.getString ("Fax");
    URL_link = rset.getString ("URL_link");
    Email = rset.getString ("Email");
    Profile = rset.getString ("Profile");
    USRegion = rset.getString ("USRegion");
    CountryName = rset.getString ("CountryName");
    %>

    Threaded Messages (3)

  2. error passing url variable[ Go to top ]

    // error msg
    org.apache.jasper.JasperException: Unable to compile class for JSPC:\bin\tomcat\work\www.smweb.cc_8080\_0002fsourcebook_0002fmaster_0002fip_0005fedit_0002ejspip_0005fedit_jsp_1.java:99: Incompatible type for declaration. Can't convert java.lang.String to int.
                    <b> int IPNumber = ""; !!!!!What's that? <b>
    //i'm not sure why it needs a string. ipnumber is a number.
    .<br>
    .<br>
    .<br>
  3. error passing url variable[ Go to top ]

    Hi,
    I took that out, but still get this error:
    java.sql.SQLException: ServerException[ODBC Warning], SQLExecDirect DB Vendor Code:-3030, State:22005. [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
    ----------
    all are text fields, besides the ipnumber (which is also a url variable). thanks for bearing w/ me

    <% int IPNumber;
       String IPName = "";
       String Address = "";
       String Address1 = "";
       String Address2 = "";
       String City = "";
       String StateRegion = "";
       String Postcode = "";
       String Phone = "";
       String Fax = "";
       String URL_link = "";
       String Email = "";
       String USRegion = "";
       String CountryName = "";
       ResultSet rset = null;

        String sql =
          "SELECT " +
    "IPNumber, IPName, Address, Address1, Address2, City, StateRegion, Postcode, " +
    "Phone, Fax, URL_link, " +
    "Email, USRegion, CountryName " +
          "FROM " +
            "IPs " +
    "WHERE " +
    "IPNumber = " +
    "'" + request.getParameter("IPNumber") + "'";

        try {
          rset = stmt.executeQuery (sql);
        }
        catch (SQLException e) {
          out.println (e);
    return;
        }

        while (rset.next ())
        {
          IPNumber = rset.getInt ("IPNumber");
    IPName = rset.getString ("IPName");
          Address = rset.getString ("Address");
          Address1 = rset.getString ("Address1");
    Address2 = rset.getString ("Address2");
    City = rset.getString ("City");
    StateRegion = rset.getString ("StateRegion");
    Postcode = rset.getString ("Postcode");
    Phone = rset.getString ("Phone");
    Fax = rset.getString ("Fax");
    URL_link = rset.getString ("URL_link");
    Email = rset.getString ("Email");
    USRegion = rset.getString ("USRegion");
    CountryName = rset.getString ("CountryName");
    %>
  4. error passing url variable[ Go to top ]

    Disregard. Figured Out.