0

hi all I am new to JSTL ,
I need to display content in JSP using JSTL.
Its Student information project I have list of students , i need to display them in jsp using jstl,

my servlet code

try {
UserList userList = dataCon.getListUsers(strClassId);
session.setAttribute("userList",userList);
response.sendRedirect("/CMS/classsearch.jsp");
} catch (Exception e) {
}
}

my database connicitivity class

public UserList getListUsers(String classId) {
            UserList userList=new UserList();
            ArrayList<User> listUsers= new ArrayList<User>();

            sql ="SELECT um.`UserId`,um.`FirstName`,um.`LastName`,um.`Address1`,um.`Address2`,um.`City`,um.`State`,um.`DOB`,um.`MailId`,at.Authorization FROM `usermaster`as um JOIN authorizationmapping as am ON um.`UserId`=am.`UserId` JOIN authorizationmaster as at ON am.`AuthorizationId`=at.AuthorizationId JOIN studentallocation as st ON st.stuid=um.`UserId`  where st.classid=?";
            try {
                pstm = con.prepareStatement(sql);
                pstm.setString(1, classId);
                rs = pstm.executeQuery();
                while (rs.next()) {
                User user = new User();
                user.setUserId(rs.getString(1));
                user.setFirstName(rs.getString(2));
                user.setLastName(rs.getString(3));
                user.setAddress1(rs.getString(4));
                user.setAddress2(rs.getString(5));
                user.setCity(rs.getString(6));
                user.setState(rs.getString(7));
                user.setDOB(rs.getString(8));
                user.setMailId(rs.getString(9));
                user.setAuthorization(rs.getString(10));
                listUsers.add(user);
                }
                userList.setListUser(listUsers);

            } catch (Exception e) {
                System.out.println("Error in sql statement"+ e.getMessage());
            }
            return userList;
        }

Could any one guide me

Edited by anand01

2
Contributors
1
Reply
5
Views
5 Years
Discussion Span
Last Post by rajesh1158
0

use JSTL taglib tags...example below:

<c:foreach var="a" list="studentList">
ID: ${a.id} - NAME: ${a.name}
</c:foreach>

id and name are fields in the student object. Dont forget to import JSTL taglib at top of page.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.