You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Lorenzo Sicilia <ar...@kemen.it> on 2002/10/31 12:55:15 UTC

jstl & jsp: working progress

thanks to all list for the aid during these days.
the quite new question

<%
//elenco is a JSTL recordSet
Result rs = (Result)pageContext.findAttribute("elenco");
int max = rs.getRowCount();

for (int fRow = 0; fRow<= max; fRow++ ){
//	out.print(rs.getRowsByIndex()[row][2]+"#");
//	out.println(fRow);  --> Output: 0,1,2,3....
//	out.print(rs.getRows()[0].data); --> Error: "No field name"
	out.print(rs.getRowsByIndex()[0][0]); // output--> 1,1,1,1,...
// 
***********************************************************************		
// 	My Problem:		
//	out.print(rs.getRowsByIndex()[fRow][0]); // Error: "<head><title>JRun 
Servlet Error</title></head><h1>500 7</h1><body>7</body>
//	***********************************************************************

}
	
%>
//	Why the fRow var is not read by the SortedMap objcet? Cast?

thanks

Lorenzo Sicilia


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: jstl & jsp: working progress

Posted by Lorenzo Sicilia <ar...@kemen.it>.
Shawn Bayern wrote:
> Once again, I'll strongly recommend that you use JSTL to access the Result
> object; it wasn't designed for easy access in Java.  What are you
> expecting to get from scriptlets in this case?

The goal is convert a recordSet in a String. Flash MX load the jsp 
output and convert in a Flash MX recordSet.

I must use jsp because I can control "\n" output. Now the output is more 
compress ^_^

I have understand some things about JAVA world thanks to all.
This is my last script with JSTL and JSP integration.


<%@ page import="javax.servlet.jsp.jstl.sql.Result" %>
<%@ taglib uri="/WEB-INF/tld/sql.tld" prefix="sql" %>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ include file="/global/connection.jsp" %>
<!-- After I use ? and getParam ^_^ -->
<c:set var="language_set" value="it" />
<sql:query var="elenco" >
SELECT 	ID_news,data,
		titolo_<c:out value="${language_set}" /> as titolo,
		abstract_<c:out value="${language_set}" /> as abstract,
		testo_<c:out value="${language_set}" /> as testo,
		data
FROM tb_news
</sql:query>

<%
// elenco is a JSTL recordSet
// RecordSet Compresion for Flash MX
// costanti per i terminatori

String tRow = "##";
String tColum = "#";
String initData = "####";

Result rs = (Result)pageContext.findAttribute("elenco");
int max = rs.getRowCount();
String[] columnNames = rs.getColumnNames();
// Start print Column
String rsString = "response=";


for (int c = 0; c < columnNames.length;c++){
	rsString += columnNames[c] + tColum;
}
// Column end
rsString += initData;
// Start print recordSet Data
for (int row = 0; row < max; row++ ){
	for (int column = 0; column < columnNames.length; column++){
		rsString += rs.getRows()[row].get(columnNames[column])+ tColum; //--> 
Error: "No field name"
	}
	rsString += tRow;
}
rsString += "&";
out.print(rsString);
%>


Best Regards Lorenzo Sicilia

-- 
"Il fatto che un'opinione sia condivisa ampiamente non prova che non sia 
completamente assurda"
Bertrand Russell


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: sql, choose and scope

Posted by Lorenzo Sicilia <ar...@kemen.it>.
flare wrote:
> perhaps you should use "and" instead of "or" :)
> 
> <c:when test="${empty param.fSessionId && empty param.sqlRequest }" >

Actualy is just a test! After I make a true autentification system. 
Anyway thanks.

Best Regards

Lorenzo Sicilia


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: sql, choose and scope

Posted by flare <fl...@flare.it>.
> <c:choose>
> <c:when test="${empty param.fSessionId || empty param.sqlRequest }" >
>   <c:out value="LOGIN KO" />
> </c:when>

> sqlRequest was correct 	but the first WHEN was always True.

perhaps you should use "and" instead of "or" :)

<c:when test="${empty param.fSessionId && empty param.sqlRequest }" >
 

 ciao 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: sql, choose and scope

Posted by Lorenzo Sicilia <ar...@kemen.it>.
Pierre Delisle wrote:
> I suspect the body of the when clause is not executed
> because its condition evaluates to false.
> 
> You should print the value of param.sqlRequest prior
> to the <c:choose> to make sure it has the value "1".
> 
>     -- Pierre

Perfect now all work fine!Before I don't had understand choose tag.

True Script:
<c:choose>
<c:when test="${empty param.fSessionId || empty param.sqlRequest }" >
		<c:out value="LOGIN KO" />
</c:when>
<c:when test="${param.sqlRequest == 1}" >
		<c:out value="Entro!" />
		<sql:query var="flashRecordSet" >
		SELECT 	ID_news,data,
			titolo_it as titolo,
			abstract_it as abstract,
			testo_it as testo
		FROM tb_news
		</sql:query>
</c:when>
</c:choose>
sqlRequest was correct 	but the first WHEN was always True.
Now I have understand is quite equal to Switch ;o)

Best Regards Lorenzo Sicilia


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: sql, choose and scope

Posted by Pierre Delisle <pi...@sun.com>.
I suspect the body of the when clause is not executed
because its condition evaluates to false.

You should print the value of param.sqlRequest prior
to the <c:choose> to make sure it has the value "1".

    -- Pierre

Lorenzo Sicilia wrote:
> 
> A problem about scope:
> 
> my script
> 
> <c:choose >
>         <c:when test="${param.sqlRequest == 1}"  >
>                         <sql:query var="flashRecordSet" >
>                         SELECT  ID_news,data,
>                                 titolo_it as titolo,
>                                 abstract_it as abstract,
>                                 testo_it as testo
>                         FROM tb_news
>                         </sql:query>
>         </c:when>
> </c:choose>
> 
> Result rs = (Result)pageContext.findAttribute("flashRecordSet");
> 
> I can't find flashRecordSet. If SQL tag is out the tags Choose and When
> all work fine.
> Some one can explain me why? I need just the path to get flashRecordSet
> 
> thanks Lorenzo Sicilia
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


sql, choose and scope

Posted by Lorenzo Sicilia <ar...@kemen.it>.
A problem about scope:

my script

<c:choose >
	<c:when test="${param.sqlRequest == 1}"  >
			<sql:query var="flashRecordSet" >
			SELECT 	ID_news,data,
				titolo_it as titolo,
				abstract_it as abstract,
				testo_it as testo
			FROM tb_news
			</sql:query>
	</c:when>
</c:choose>


Result rs = (Result)pageContext.findAttribute("flashRecordSet");

I can't find flashRecordSet. If SQL tag is out the tags Choose and When 
all work fine.
Some one can explain me why? I need just the path to get flashRecordSet

thanks Lorenzo Sicilia


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: jstl & jsp: working progress

Posted by Shawn Bayern <ba...@essentially.net>.
On Thu, 31 Oct 2002, Lorenzo Sicilia wrote:

> // Why the fRow var is not read by the SortedMap objcet? Cast?

Java doesn't work like that.  You can't write sortedMap[foo] in Java.  You
have to write sortedMap.get("foo").

Once again, I'll strongly recommend that you use JSTL to access the Result
object; it wasn't designed for easy access in Java.  What are you
expecting to get from scriptlets in this case?

-- 
Shawn Bayern
"JSTL in Action"   http://www.jstlbook.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>