2

In my JSP page I am displaying the employee detail in the DB and giving the table column name in the form of hard coded.now I need to know how to get the table column name dynamically ?

I aware of ResultSetMetaData to use it only in JSP. But I don't know how to get the column name when using the Spring-Hibernate Integration in JSP.

Please any one help to solve this?

My JSP page will be ,

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ include file="include.jsp" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

<form:form action="displayuser.html"  commandName="displayuser">  


<table width="100%" align="center">

 <tr style="background-color:#6B8E23  ;">
  <td align="center">Employee Id</td>
  <td align="center">Employee Name</td>
  <td align="center">Employee Password</td>
    <td align="center">Gender</td>
  <td align="center">Designation</td>
 </tr>

 <core:forEach items="${DisplayuserDetail}" var="userObj">
    <tr style="background-color:#9ACD32 ;">
       <td align="center"><core:out value="${userObj.empId}"/></td>
       <td align="center"><core:out value="${userObj.empName}"/></td>
       <td align="center"><core:out value="${userObj.empPassword}"/></td>
       <td align="center"><core:out value="${userObj.gender}"/></td>
       <td align="center"><core:out value="${userObj.designation}"/></td>
    </tr>
 </core:forEach>

</table>

</form:form>

</body>
</html>

Thanks in advance ... and your help will be appreciated ...

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Human Being
  • 8,269
  • 28
  • 93
  • 136

1 Answers1

1

If your Hibernate persistent objects use annotations you could read the annotations off the domain objects.

Alternatively, see if the answers to this question on getting SQL column names are helpful.

Community
  • 1
  • 1
Nathan Hughes
  • 94,330
  • 19
  • 181
  • 276