Retrive values from an arraylist and display in a jsp?

Retrive values from an arraylist and display in a jsp?

Hi,

I need help in jsp to display values of an ArrayList in jsp.

There is a java file containing a method which is returning an ArrayList.

I want to display the records of the ArrayList in jsp in a tabular form/way.

if (request.getParameter("action") != null) { Open connection to the database; Read parameters from the JSP formular (parameters are NAME and YEAR of each student); stmt.executeUpdate("insert into Students(name,year) values('"+name+"', '"+year+"')"); Close the connection;

ArrayList<Student> students = StudentsManager.getInstance().getStudents();
    %>
    <html>
    <body bgcolor=#4AA02C>
    <center>
        <h2>Student list</h2>
        <table border="1" cellspacing="1" cellpadding="8" bgcolor= #EBDDE2> 
        <tr>
            <td bgcolor= #FF9966><b>ID</b></td>
            <td bgcolor= #FF9966><b>Name</b></td>
            <td bgcolor= #FF9966><b>Year</b></td>
        </tr>
            <%
            int no = 1;
            Student s = students.get(no); 
            %>
            <tr>
              <td><%= no %></td>
              <td><%= s.getName();%></td>
              <td><%= s.getYear();%></td>
            </tr>
            <%
            no++;
}

%>

(First RED X)<%}else{%>

   <jsp:forward page = "Student.jsp"/> // Student.jsp is the form where name and year of a student 
                                                       //    is requested to be entered to the database
(2nd RED X)  <%>}%>

1st red X: syntax error on token else, finally expected.

2nd red X: Multiple annotations found at this line: -syntax error on token catch┬?, Identifier expected - syntax error on token }┬?, delete this token - syntax error on token >, delete this token else

View Answers

June 24, 2012 at 4:08 AM

I noticed the problem now. hehe...forget


June 25, 2012 at 11:02 AM

Anyways, here is a link. It might be helpful for you.

http://www.roseindia.net/jsp/servlet-jsp-data-list.shtml









Related Tutorials/Questions & Answers:
Retrive values from an arraylist and display in a jsp?
Retrive values from an arraylist and display in a jsp?
Advertisements
Arraylist from row values
JSP1
Radio button with values from a String ArrayList in JSP?
Retrive Values
retrive values - JSP-Servlet
JSP2
retrive values - JSP-Servlet
How to Display values from databse into table
How to update table column from the values of Arraylist in java
Protect JSPs from direct access
how to display values from database into table using jsp
dispalying arraylist values in table form
Remove duplicates from ArrayList
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST
retrive data from database?
retrive data from database
cannot display an arrayList in JSP
To retrive data from database - Struts
set the arraylist values - Struts
retrive data from oracle to jsp
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST
How to Display Next question from database after clicking Next Button using "Arraylist concept"
store and retrive image from the database
search an element in arraylist and display in jsp page
GWT -- retrive the data from Database
Want to display Arraylist items on same row in JSF
retrive record from the text field and insert into to database
how to display or retrive an image in jsp whose path is stored in oracle database
How to display all the Select values from the MySQL database table in where condition= In JSP?
How to display nested ArrayList in JSF
ModuleNotFoundError: No module named 'jspp'
ModuleNotFoundError: No module named 'JSPy'
store and retrive image from database - JDBC
Remove checked checkboxes from arraylist and dipaly remaining arraylist
store & retrive the image from oracle database
retrive data from database using jsp in struts?
display all the values on next page
how to display each arraylist value on new page in jsp
Request URl using Retrive data from dtabase
insert and retrive image from sql server database in jsp
retrive image from database using jsp without stream
java [ cannot retrive date from sql ] why??
Retrive the data from the table in data base using jdbc
How to retrive an inmage from database and displaying it in imgae box - Swing AWT
ArrayList from JSP to Servlet - JSP-Servlet
retrive the employee details with image from mysql database using jsp servlet
how retrive data from google analystics dashbord on the client machine

Ads