Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Jsp code Error

  1. #1
    Junior Member
    Join Date
    Aug 2022
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Jsp code Error

    Here i want to display 3rows of mysql table in output. it shows 7errors how to solve this error? pls tell

    <%@page import = "java.sql.DriverManager,java.sql.Connection,java.s ql.Statement,java.sql.ResultSet,java.sql.SQLExcept ion, java.util.Vector" %>
    <%
    Statement stmt = null;
    Connection con = null;
    ResultSet rsT = null;

    boolean errFlag = false;
    String str = null;

    String sdbName, sregion,sregion1,sregion2,
    sdbName = request.getParameter("scaleup");
    sregion = request.getParameter("region");
    sregion1 = request.getParameter("region1");
    sregion2 = request.getParameter("region2");

    int result=0;

    try
    {
    Class.forName("com.mysql.jdbc.Driver");
    con = DriverManager.getConnection("jdbc:mysql://127.0.0.1/" + sdbName,"root","");
    stmt = con.createStatement();

    //System.out.println("select * from scaleupdata where sregion= '" + region + "' and sregion1='" + region1 + "' and sregion2='" + region2 + "'");
    rsT = stmt.executeQuery("select * from scaleupdata where sregion= '" + region + "' and sregion1='" + region1 + "' and sregion2='" + region2 + "'");

    if(rsT.next())
    {
    result=0;
    result= rsT.getInt(1);
    result= rsT.getInt(2);
    result= rsT.getInt(3);

    <table border='1'>
    <tr>
    <th>region</th>
    <th>region1</th>
    <th>region2</th>
    </tr>
    <tr>
    <td><%result=rst.getInt(1);%></td>
    <td><%result=rst.getInt(2);%></td>
    <td><%result=rst.getInt(3);%></td>
    </tr>
    </table>

    }
    rsT.close();

    System.out.println("result "+result);

    if(result==1)
    {
    str = "<center><h2>You Have Entered Invalid details</h2></center>";

    }
    else
    {

    %><jsp:forward page="Login.jsp"/>;<%

    }

    stmt = null;
    con = null;
    rsT = null;
    }
    catch(SQLException sqle)
    {
    str = "<h2>Error : " + sqle + "</h2>";
    errFlag = true;
    }
    %>


    <p><%=str%></p>

    Error:

    Generated servlet error:
    [javac] Since fork is true, ignoring compiler setting.
    [javac] Compiling 1 source file
    [javac] Since fork is true, ignoring compiler setting.
    [javac] C:\Program Files (x86)\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\SCALEUP\report_jsp .java:91: illegal start of expression
    [javac]
    [javac] ^
    [javac] C:\Program Files (x86)\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\SCALEUP\report_jsp .java:68: sdbName is already defined in _jspService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
    [javac] sdbName = request.getParameter("scaleup");
    [javac] ^
    [javac] C:\Program Files (x86)\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\SCALEUP\report_jsp .java:82: cannot resolve symbol
    [javac] symbol : variable region
    [javac] location: class org.apache.jsp.report_jsp
    [javac] rsT = stmt.executeQuery("select * from scaleupdata where sregion= '" + region + "' and sregion1='" + region1 + "' and sregion2='" + region2 + "'");
    [javac] ^
    [javac] C:\Program Files (x86)\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\SCALEUP\report_jsp .java:82: cannot resolve symbol
    [javac] symbol : variable region1
    [javac] location: class org.apache.jsp.report_jsp
    [javac] rsT = stmt.executeQuery("select * from scaleupdata where sregion= '" + region + "' and sregion1='" + region1 + "' and sregion2='" + region2 + "'");
    [javac] ^
    [javac] C:\Program Files (x86)\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\SCALEUP\report_jsp .java:82: cannot resolve symbol
    [javac] symbol : variable region2
    [javac] location: class org.apache.jsp.report_jsp
    [javac] rsT = stmt.executeQuery("select * from scaleupdata where sregion= '" + region + "' and sregion1='" + region1 + "' and sregion2='" + region2 + "'");
    [javac] ^
    [javac] C:\Program Files (x86)\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\SCALEUP\report_jsp .java:101: cannot resolve symbol
    [javac] symbol : variable rst
    [javac] location: class org.apache.jsp.report_jsp
    [javac] result=rst.getInt(2);
    [javac] ^
    [javac] C:\Program Files (x86)\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\SCALEUP\report_jsp .java:104: cannot resolve symbol
    [javac] symbol : variable rst
    [javac] location: class org.apache.jsp.report_jsp
    [javac] result=rst.getInt(3);
    [javac] ^
    [javac] 7 errors

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Jsp code Error

    Also posted here: https://coderanch.com/t/753593/java/JSP-code-Error

    Please read: http://www.javaprogrammingforums.com...s-posting.html
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Need help with my code (Unreachable code error)
    By Prexxy in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 30th, 2018, 10:18 AM
  2. Replies: 3
    Last Post: May 8th, 2014, 06:25 AM
  3. Replies: 4
    Last Post: January 24th, 2013, 11:20 AM
  4. Replies: 7
    Last Post: January 24th, 2013, 10:41 AM
  5. Code is giving an error in console, but there are no errors apparent in the code!
    By JamEngulfer221 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 15th, 2011, 09:30 PM