Hi,
Well to start od i decided to learn how to create jsp pages and finally finish my project. So i used the netbeans tutorial for making jsp pages. The sample worked fine, but when i wanted ti retrieve information from my own database it do not work like it suppose to be.
The entire point of this code is as follows:
From index.jsp i select a product
Then i'm directed to response page which shows the info of the selected product
It should display product id, name, product_type's name.
But it does not do so. It shows nicely the product id, name, but not the product_type's name. It just shows this field as empty. Product_type is also a foreign key in product table.
When i run this query in mysql database i get the result which i want:
SELECT property.property, property.name AS name, property_type.name AS property_type, property_type.description AS description FROM property, property_type WHERE property.property_type=property_type.property_type
______
id name type
1 bla blah
But in context to this entire code i the product_type won't show, it is just a blank field.
<%--
Document : response
Created on : 4.08.2008, 13:40:55
Author : kohuke
--%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<sql:query var="varaderida" maxRows="1" dataSource="jdbc/varad">
SELECT property.property, property.name AS name, property_type.name AS property_type,
property_type.description AS description
FROM property, property_type
WHERE property.property_type=property_type.property_type AND
property.property = ? <sql:param value="${param.property}"/>
</sql:query>
<c:set var="varader" scope="request" value="${varaderida.rows[0]}"/>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title> ${varader.name}</title>
</head>
<body>
<table border="0">
<thead>
<tr>
<th colspan="2">Vara: ${varader.property}</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>ID: </strong></td>
<td>${varader.property}</td>
</tr>
<tr>
<td><strong>Nimi: </strong></td>
<td>${varader.name}
</td>
</tr>
<tr>
<td><strong>Liik: </strong></td>
<td>${varader.property_type}
</td>
</tr>
</tbody>
</table>
</body>
</html>
When i change
SELECT property.property, property.name AS name, property_type.name AS property_type,
property_type.description AS description
FROM property, property_type
WHERE property.property_type=property_type.property_type AND
property.property = ? <sql:param value="${param.property}"/>
property_type.name to property.property_type (That means i'll just display the foreign key, not the name value which the foreign key should be related to...) it shows the spesific value as a number which it should do.
Can you someone please give me tip what should i do to fix this problem. Of course i can leave it like this, but then again it will be very unfair to the "end user" who has to guess what the numbers mean.