Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javax.el.PropertyNotFoundException: Property 'empname' not found on type java.lang.String

 
vijay dadhwal
Ranch Hand
Posts: 47
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I am using jstl sql tag for fectching data from a access database using odbc:jdbc driver
here is the code:

[code]
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c-1_0.tld"%>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<sql:setDataSource driver="sun.jdbc.odbc.JdbcOdbcDriver" url="jdbc:odbc:msd" user="softvijay" password="softpower" />
<sql:query var="result" >
select empname from emp
</sql:query>
<TABLE BORDER="1">
<c:forEach var="row" items="${result}">
<TR>
<td><c:out value="${row.empname}"/> </td>
</TR>
</c:forEach>
</TABLE>

The problem is that i am getting error message as "javax.el.PropertyNotFoundException: Property 'empname' not found on type java.lang.String"
although there is a field in table 'emp' with name 'empname'

what is the cause ?
need help

regards
vijay

 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check the database column name, empname should be a column name
 
vijay dadhwal
Ranch Hand
Posts: 47
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for Response,

But 'empname' is the column name, below is the 'emp' table structure

ID empname
2 anubhav
3 raghav
1 vijay

Regards
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64194
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this prototype code? The JSTL SQL tags should not be used in production code.
 
vijay dadhwal
Ranch Hand
Posts: 47
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Sir,

Pleasure to hear from you.

As you stated

Is this prototype code? The JSTL SQL tags should not be used in production code.
i have one more doubt which is :-
(1) can we not use jstl sql tags in commercial production?

Back to my problem , i am just connecting the jsp page having sql:query with Msaccess 2007 DB.

What could be the problem ?

Regards
vijay

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64194
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vijay dadhwal wrote:can we not use jstl sql tags in commercial production?

It is not advised. Doing database access in the view is a serious breach of the principle of Separation of Concerns and against all modern best practices. Even the JSTL Specification itself advises not to use these tags in anything other than quick prototypes.
 
vijay dadhwal
Ranch Hand
Posts: 47
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for response sir,

i agree with you that DataBases acccess should be used with Either Servlets (controller) or Model (EJB) not with Views (JSP).

But my concern is also thay why this error is coming ? If there is JSTL TAG for sql:query & sql:setDataSoruce then it should be working.

All seems ok with my code, it is able to go to Table Level but not able to access the columns under it.

What could reason for this error ?

Regards
 
vijay dadhwal
Ranch Hand
Posts: 47
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

Error solved !!!,

i was actually using wrong Core Tld
By making to uri="http://java.sun.com/jsp/jstl/core"
it got solved.

Regards
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic