• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Ranch Hand
Posts: 47
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
check the database column name, empname should be a column name
 
vijay dadhwal
Ranch Hand
Posts: 47
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic