aspose file tools*
The moose likes JSP and the fly likes javax.el.PropertyNotFoundException: Property 'empname' not found on type java.lang.String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "javax.el.PropertyNotFoundException: Property Watch "javax.el.PropertyNotFoundException: Property New topic
Author

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

vijay dadhwal
Ranch Hand

Joined: Dec 02, 2008
Posts: 47

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


MCA , SJCP
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

check the database column name, empname should be a column name


Love all, trust a few, do wrong to none.
vijay dadhwal
Ranch Hand

Joined: Dec 02, 2008
Posts: 47

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

Joined: Jan 10, 2002
Posts: 61769
    
  67

Is this prototype code? The JSTL SQL tags should not be used in production code.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
vijay dadhwal
Ranch Hand

Joined: Dec 02, 2008
Posts: 47

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

Joined: Jan 10, 2002
Posts: 61769
    
  67

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

Joined: Dec 02, 2008
Posts: 47

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

Joined: Dec 02, 2008
Posts: 47

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
 
subject: javax.el.PropertyNotFoundException: Property 'empname' not found on type java.lang.String