This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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

 
Ranch Hand
Posts: 47
Eclipse IDE Hibernate Java
  • 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

 
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • 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
  • 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
 
Author and ninkuma
Marshal
Posts: 66790
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
  • 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
Posts: 66790
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
  • 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
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!