Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7856795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:49:17+00:00 2026-06-02T20:49:17+00:00

Thank you for reading this Question. CODE BELOW I’m trying to get a jsp

  • 0

Thank you for reading this Question.

CODE BELOW

I’m trying to get a jsp working with a database. The database is currently partially populated and I am trying to get this information back to my browser and print it out.

Unfortunately, when I try this I get an error saying that the compiler cannot find symbol ‘studentData’ on the line where I try to call getStudentList() in newjsp.jsp.

I have copied the code that’s in newjsp from a friend’s project where it works fine.

I hope you can help!

Thanks,

planty182

********* StudentBean.java *****

         package my.beans;


         public class StudentBean {


                 private String firstName;
                 private String lastName;
                 private String comment;
                 private String email;

                 public StudentBean(){

                 }

                 // get/set for First Name
                 public void setFirstName(String firstName) {
                         this.firstName = firstName;
                 }
                 public String getFirstName(){
                         return firstName;
                 }

                 // get/set for Last Name
                 public void setLastName(String lastName) {
                         this.lastName = lastName;
                 }
                 public String getLastName(){
                         return lastName;
                 }

                 // get/set for comment
                 public void setComment(String comment) {
                         this.comment = comment;
                 }
                 public String getComment(){
                         return comment;
                 }

                 // get/set for Email
                 public void setEmail(String email) {
                         this.email = email;
                 }
                 public String getEmail(){
                         return email;
                 }
         }

**** StudentDataBean.java ********

         package my.beans;

         import java.sql.SQLException;
         import javax.sql.rowset.CachedRowSet;
         import java.util.ArrayList;
         import com.sun.rowset.CachedRowSetImpl; // CachedRowSet implementation

         public class StudentDataBean {

            private CachedRowSet rowSet;

            // construct TitlesBean object
            public StudentDataBean() throws Exception
            {
               // load the MySQL driver
               Class.forName( "com.mysql.jdbc.Driver" );

               // specify properties of CachedRowSet
               rowSet = new CachedRowSetImpl();
               rowSet.setUrl( "jdbc:mysql://localhost:3306/test" );
               rowSet.setUsername( "root" );
               rowSet.setPassword( "" );

                   // obtain list of titles
               rowSet.setCommand(
                  "SELECT firstName, lastName, email, comment FROM guests" );
               rowSet.execute();
            } // end StudentDataBean constructor

            // return an ArrayList of StudnetBeans
            public ArrayList<StudentBean> getStudentList() throws SQLException
            {
               ArrayList<StudentBean> studentList = new ArrayList<StudentBean>();

               rowSet.beforeFirst(); // move cursor before the first row

               // get row data
               while ( rowSet.next() )
               {
                  StudentBean student = new StudentBean();

                  student.setFirstName( rowSet.getString( 1 ) );
                  student.setLastName( rowSet.getString( 2 ) );
                  student.setEmail( rowSet.getString( 3 ) );
                  student.setComment( rowSet.getString( 4 ) );
                  studentList.add( student );
               } // end while

               return studentList;
            } // end method getStudentList

            // insert a Student in student database
         public void addStudent( StudentBean student ) throws SQLException
         {
         rowSet.moveToInsertRow(); // move cursor to the insert row

          // update the three columns of the insert row
         rowSet.updateString( 1, student.getFirstName() );
         rowSet.updateString( 2, student.getLastName() );
         rowSet.updateString( 3, student.getEmail() );
         rowSet.updateString( 4, student.getComment() );
         rowSet.insertRow(); // insert row to rowSet
         rowSet.moveToCurrentRow(); // move cursor to the current row
         rowSet.acceptChanges(); // propagate changes to database
         } // end method addStudent
    } // end class StudentDataBean

****** newjsp.jsp ***********

   <%@page import="java.util.ArrayList"%>
   <%@page contentType="text/html" pageEncoding="UTF-8"%>
   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

   <%@ page import="java.util.*" %>
   <%@ page import="my.beans.StudentDataBean"%>
   <%@ page import="my.beans.StudentBean"%>
   <jsp:useBean id="studentData" scope="request" class="my.beans.StudentDataBean"/>
   <html>
     <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
         <title>Words View</title>
           <style type="text/css">
           table, tr, td, th
           {
                text-algn: center;
                font-size: .9em;
                border: 3px groove;
                padding: 3px;
                background-color: #eee9e9;
           }
     </style>
     </head>
     <body>
     <h1>Student List</h1>
     <table border="1">
        <tr>
            <th>
                <h4>Email</h4>
            </th>
            </tr>
                <%
                    ArrayList<StudentBean> studentList = studentData.getStudentList();
                    Iterator studentListIterator = studentList.iterator();
                    StudentBean student;

                    while (studentListIterator.hasNext()){
                        student = (StudentBean) studentListIterator.next();
                %>
            <tr>
                <td><%= student.getEmail()%></td>

            </tr>
            <% }
            %>
     </table>
     </body>
     </html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:49:19+00:00Added an answer on June 2, 2026 at 8:49 pm

    might be an ide error, restart netbeans. (if youre using netbeans… otherwise god knows.) love Tom xx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm reading an application configuration file form the code pasted below. My question is
Thanks in Advance for reading and answer this question. I got button in asp
I was reading this post and had a question that I didn't think it
Hello and thanks to everyone for reading my question. I've been working on a
Ok, this is perplexing me... The code below is in a DLL, and when
I believe this question is worth reading, in my opinion... I've tried to explain
This question is challenging to get more understanding on Image Processing using pure C.
just was reading this article http://highscalability.com/blog/2010/3/23/digg-4000-performance-increase-by-sorting-in-php-rather-than.html And found this nice article http://wiki.apache.org/cassandra/DataModel I just
Thank you very much in advance for reading. I'm programming a web application in
I am attempting to write this type of program as stated in the question.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.