Below is the code I wrote in body
<% List<UserInfo> userInfoList = new ArrayList<UserInfo>();
UserInfo userInfo = new UserInfo();
userInfoList = new CRUDOps().retrieveUserDataList();
pageContext.setAttribute("userInfoList", userInfoList);%>
Below is the code I wrote in div
<c:forEach var="userInfo" items="${userInfoList}">
<input type="radio" name="buyer" value="hhhh">${userInfo.get(0).getFirstName()}/><br />
<c:forEach>
Above code , have to display first and last name from UserInfo table … UserInfoList contains UserInfo object and UserInfo has first and last names. So, using userInfoList with index value as “0” calling the getFirstName defined in POJO.
The error that I am getting is
org.apache.jasper.JasperException: /requestorGroup.jsp(63,59) The function get must be used with a prefix when a default namespace is not specified
If
UserInfohas a first name and a last name, anduserInfois of typeUserInfo, callingget(0)on it makes no sense: it’s not a list, and it doesn’t have any first element. It has a first name and a last name.You simply need
The JSP expression language (EL) accesses properties via getters. So you shouldn’t use the getter, but simply the name of the property:
firstName.You should also avoid scriptlets in JSP, and put the code which gets data from the database into a servlet instead. Moreover, two out of the 4 lines are completely unnecessary. The code should be reduced to: