Hi, I am using DBtag, and amongst the fields in the table I have a TEXT
field, I want to display all the fields and only the three words of the
column that is a TEXT field.
could you please help.
Thanks lot.
-
display only first three words ..? (4 messages)
- Posted by: majid abdel
- Posted on: October 18 2001 15:42 EDT
Threaded Messages (4)
- display only first three words ..? by Igor Putrenko on October 22 2001 04:47 EDT
- display only first three words ..? by majid abdel on October 22 2001 10:22 EDT
-
display only first three words ..? by Igor Putrenko on October 22 2001 11:05 EDT
- Java StringTokenizer tutorial ,Java Token by jim woods on June 25 2006 04:37 EDT
-
display only first three words ..? by Igor Putrenko on October 22 2001 11:05 EDT
- display only first three words ..? by majid abdel on October 22 2001 10:22 EDT
-
display only first three words ..?[ Go to top ]
- Posted by: Igor Putrenko
- Posted on: October 22 2001 04:47 EDT
- in response to majid abdel
You should pass it (the sb object) to your text fields this way approximately:
StringTokenizer st = new StringTokenizer(String yourString);
StringBuffer sb = new StringBuffer();
int i = 0;
while (st.hasMoreTokens()) {
if (i >= 2)
break;
i++;
sb.append(st.nextToken());
}
-
display only first three words ..?[ Go to top ]
- Posted by: majid abdel
- Posted on: October 22 2001 10:22 EDT
- in response to Igor Putrenko
Hi, I am using DBtag in tomcat with Mysql, one of the fields of a table in
the database is a TEXT field, I want to display only the three first word
of
that field as a link, here is what I did :
<sql:preparedStatement id="stmt6" conn="conn1">
<sql:query>
select * from reward
</sql:query>
<sql:resultSet id="rset4">
<%
StringTokenizer st = new StringTokenizer(<sql:getColumn
position="6"/>);
StringBuffer sb = new StringBuffer();
int i = 0;
while (st.hasMoreTokens()) {
if (i >= 3)
break;
i++;
sb.append(st.nextToken());
}
%>
<pg:item>
<tr bgcolor="#eeeeff">
<td><sql:getColumn position="2"/></td>
<td><sql:getColumn position="6"/></td>
<td> <%= sb %></td>
</tr>
</pg:item>
</sql:resultSet>
Here is the error I got :
Error: 500
Location: /abovebeyond/ThisMonth.jsp
Internal Servlet Error:
org.apache.jasper.JasperException: Unable to compile class for
JSPC:\tomcat323\work\localhost_8080%2Fabovebeyond\_0002fThisMonth_0002ejspThisMonth_jsp_33.java:321:
Missing term.
StringTokenizer st = new StringTokenizer();
^
C:\tomcat323\work\localhost_8080%2Fabovebeyond\_0002fThisMonth_0002ejspThisMonth_jsp_33.java:321:
')' expected.
StringTokenizer st = new StringTokenizer();
^
2 errors
thanks -
display only first three words ..?[ Go to top ]
- Posted by: Igor Putrenko
- Posted on: October 22 2001 11:05 EDT
- in response to majid abdel
Off course this is wrong. You should pass to the StringTokenizer constructor the String object - You know, java.lang.String, not any things like that:
new StringTokenizer(<sql:getColumn position="6"/>);
This is absolutely wrong. So You ought to create a String object first with the appropriate text You need.
-
Java StringTokenizer tutorial ,Java Token[ Go to top ]
- Posted by: jim woods
- Posted on: June 25 2006 04:37 EDT
- in response to Igor Putrenko