Forum Moderators: coopster

Message Too Old, No Replies

Java Syntax for Extracting Vars from SQL

Need help with getting data out...

         

BobOConnor

3:40 pm on Aug 23, 2005 (gmt 0)

10+ Year Member



I am new to using Java/Tomcat/MYSQL
and I have this TAG file and can get
the data out in the loop at the end
but not inside the *DOESN"T WORK*

What I am trying to do is get
the userName and name out ONE TIME
as the header BEFORE the loop data.

It turns out that for Every ROW,
the userName and name are the same
and I expect it is some simple
extraction.

[codes]
<sql:query var="q">
SELECT s.userName,s.subscriberTypeCode,s.name,b.pKey,b.title,
b.blogTypeCode, b.allowCommentFlag, b.createTimestamp
FROM Blog b, Subscriber s
WHERE s.userName =?
AND b.memberKey = s.pKey
AND s.subscriberTypeCode = 'M'
AND b.blogTypeCode = 'B'
AND b.publishFlag = 'Y'
ORDER BY b.createTimestamp DESC
LIMIT 5;
<sql:param value="${enroller.userName}"/>
</sql:query>

<c:set var="hotBlogs" value="<%= new java.util.LinkedHashMap() %>"/>
<c:forEach var="r" items="${q.rows}" varStatus="i">
<c:set target="${hotBlogs}" property="${i.index}" value="${r}"/>
</c:forEach>

<c:set target="${hotstuff}" property="BLOGS" value="${hotBlogs}"/>

***THIS SECTION DOESN'T WORK Vars not show***

<title><c:out value="${r.value.name}"/>'s Blogs</title>
<link>http://<c:out value="${r.value.userName}"/>.powerfulintentions.com</link>
<description>List of <c:out value="${r.value.name}"/>'s BLOG entries.</description>

***END DOESN'T WORK***

<c:forEach var="r" items="${hotstuff['BLOGS']}" varStatus="i">
<item>
<title>${r.value.title}</title>
<link>http://${r.value.userName}.${qp:getApplicationBase(pageContext)}/blog/article/${r.value.pKey}/?comments=Y</link>
<description>${r.value.title}</description>
</item>
</c:forEach>[/codes]

Thanks in Advance.

-Bob OConnor

PS: this was the closest forum to my subject
I could find. Let me know if there is a better choice
for Server Side Java Questions.

BobOConnor

6:00 pm on Aug 23, 2005 (gmt 0)

10+ Year Member



Ok, I wandered around and solved my problem using
these lines:


**Placed After sql and above loop**
...
<c:set var="tname" value="${q.rows[0].name}"/>
<c:set var="tuserName" value="${q.rows[0].userName}"/>
...
**and displayed **
...
<title>${tname}'s Blogs</title>
<link>http://${tuserName}.powerfulintentions.com</link>
<description>List of ${tname}'s BLOG entries.</description>
...

Simple, really. Now the only question is where to
post additional JAVA/Tomcat/MySQL questions?

-Bob O