Thread: Problems in JSP

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    1
    Rep Power
    0

    Unhappy Problems in JSP


    Lately, I've been having problems with JSP coding. I get the error message:

    org.apache.jasper.JasperException: Unable to compile class for JSPC:\tomcat\work\localhost_8080\_0002fRegister_0002ejspRegister_jsp_3.java:104: Method If(boolean) not found in class _0002fRegister_0002ejspRegister_jsp_3.
    If(gpass.compareTo(gcpass)!=0); ^

    which I really don't know what it means. I try to use the if-else statement, but it says method not found. My other pages have similar code but I don't get this error message and I dont need the ; at the end of an If statement.

    Anyway here's, the full code for dissection (It's actually a register account page):

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body bgcolor="#FFFFFF" text="#000000">
    <div align="center">
    <p>Enter new account information</p>
    <form action="Register.jsp" method="GET">
    <p>&nbsp;</p>
    <table width="49%" border="2" cellspacing="2" cellpadding="0">
    <tr>
    <td width="38%">
    <div align="left"><font color="#FF0000">First name*:</font></div>
    </td>
    <td width="62%">
    <div align="left">
    <input type="text" name="fname" size="50">
    </div>
    </td>
    </tr>
    <tr>
    <td width="38%">
    <div align="left"><font color="#FF0000">Last name:</font></div>
    </td>
    <td width="62%">
    <div align="left">
    <input type="text" name="lname" size="50">
    </div>
    </td>
    </tr>
    <tr>
    <td width="38%" height="19">
    <div align="left"><font color="#FF0000">Email address*:</font></div>
    </td>
    <td width="62%" height="19">
    <div align="left">
    <input type="text" name="email" size="30">
    </div>
    </td>
    </tr>
    <tr>
    <td width="38%">
    <div align="left"><font color="#FF0000">Username*:</font></div>
    </td>
    <td width="62%">
    <div align="left">
    <input type="text" name="username" size="30">
    </div>
    </td>
    </tr>
    <tr>
    <td width="38%" height="18">
    <div align="left"><font color="#FF0000">Choose a password*:</font></div>
    </td>
    <td width="62%" height="18">
    <div align="left">
    <input type="text" name="password" size="30">
    <font color="#FF0000"> (Min of 8 characters!)</font></div>
    </td>
    </tr>
    <tr>
    <td width="38%">
    <div align="left"><font color="#FF0000">Re-enter password*:</font></div>
    </td>
    <td width="62%">
    <div align="left">
    <input type="text" name="cpassword" size="30">
    </div>
    </td>
    </tr>
    <tr>
    <td width="38%">
    <div align="left"><font color="#FF0000">Gender*:</font></div>
    </td>
    <td width="62%">
    <div align="left">
    <input type="radio" name="gender" value="Male" checked>
    Male
    <input type="radio" name="gender" value="Female">
    Female</div>
    </td>
    </tr>
    <tr>
    <td width="38%" height="20"><font color="#FF0000">Birth date*:</font></td>
    <td width="62%" height="20">
    <div align="left">
    <select name="day">
    <option selected>Day</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    <option value="10">10</option>
    <option value="11">11</option>
    <option value="12">12</option>
    <option value="13">13</option>
    <option value="14">14</option>
    <option value="15">15</option>
    <option value="16">16</option>
    <option value="17">17</option>
    <option value="18">18</option>
    <option value="19">19</option>
    <option value="20">20</option>
    <option value="21">21</option>
    <option value="22">22</option>
    <option value="23">23</option>
    <option value="24">24</option>
    <option value="25">25</option>
    <option value="26">26</option>
    <option value="27">27</option>
    <option value="28">28</option>
    <option value="29">29</option>
    <option value="30">30</option>
    <option value="31">31</option>
    </select>
    /
    <select name="month">
    <option selected>Month</option>
    <option value="01">January</option>
    <option value="02">February</option>
    <option value="03">March</option>
    <option value="04">April</option>
    <option value="05">May</option>
    <option value="06">June</option>
    <option value="07">July</option>
    <option value="08">August</option>
    <option value="09">September</option>
    <option value="10">October</option>
    <option value="11">November</option>
    <option value="12">December</option>
    </select>
    /
    <input type="text" name="year" size="4">
    </div>
    </td>
    </tr>
    <tr>
    <td width="38%" height="22">
    <div align="left"><font color="#FF0000">Country*:</font></div>
    </td>
    <td width="62%" height="22">
    <div align="left">
    <input type="text" name="country" size="30">
    </div>
    </td>
    </tr>
    </table>
    <p>All fields marked with an asterisk must be filled.</p>
    <p>To complete registration, click here
    <input type="submit" name="submit" value="Register">
    </p>
    </form>
    </div>

    <%

    String submit = request.getParameter("submit");
    if(submit == null)
    {
    %>
    <%
    }
    else
    {
    %>

    <%@ page language="java" import="java.sql.*" %>

    <%

    String host="localhost";
    String user="root";
    String password="qwerty12";
    String conn="jdbc:mysql://127.0.0.1/Userdata";

    String gfname=request.getParameter("fname");
    String glname=request.getParameter("lname");
    String gemail=request.getParameter("email");
    String gusername=request.getParameter("username");
    String gpass=request.getParameter("password");
    String gcpass=request.getParameter("cpassword");
    String ggender=request.getParameter("gender");
    String gday=request.getParameter("day");
    String gmonth=request.getParameter("month");
    String gyear=request.getParameter("year");
    String gcountry=request.getParameter("country");
    String full_dob = gmonth + "/" + gday + "/" + gyear;
    String check1="1";
    String check2="1";

    If(gpass.compareTo(gcpass)!=0);
    {
    out.println("<p>Some fields were uncompleted. Please re-enter.</p>");
    check1="0";
    }

    If(check1.compareTo(check2)==0);
    {
    Class.forName("org.gjt.mm.mysql.Driver");
    Connection Conn = DriverManager.getConnection(conn, user, password);
    Statement SQLStatement = Conn.createStatement();
    String Query = "INSERT INTO userinfo (Firstname, Lastname, Email, Username, Password, Gender, DateOfBirth, Country) VALUES ('" + gfname + "', '" + glname + "', '" + gemail + "', '" + gusername + "', '" + gpass + "', '" + ggender + "', '" + full_dob + "', '" + gcountry + "')";

    int SQLStatus = SQLStatement.executeUpdate(Query);
    if(SQLStatus != 0)
    {
    out.println("You have succesfully registered.");
    out.println("<h1>Click <a href=New.jsp>here</a> to login</h1>");
    }
    else
    {
    out.println("Error! Please try again.");
    }

    SQLStatement.close();
    Conn.close();
    }
    }
    </body>
    </html>
    %>

    I appreciate any help on this. Thanks a million!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    Belarus
    Posts
    30
    Rep Power
    13
    hi, isan_k
    you should use small letters in if statement, only lower case.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    1
    Rep Power
    0

    Thanks!


    Actually, I found out the problem just yesterday, thanks to my lecturer who took one glance and told me what was wrong. Anyway, thanks for your reply to my question. It certainly teaches me a lesson to look at my code more carefully the next time.

    Java is case-sensitive folks, so please remember or else you'll go crazy like I did trying to look for the error

IMN logo majestic logo threadwatch logo seochat tools logo