Re: jrun jstl

2002-10-30 Thread Shawn Bayern
On Wed, 30 Oct 2002, Lorenzo Sicilia wrote:

 The Sql tag is very usefull but I read in JSTL in ACTION that it don't 
 support pooling connection. Is true?

The sql:setDataSource tag, when used to create a DataSource, doesn't
support pooling (unless you somehow have a pooling JDBC driver, which
isn't the way things are supposed to work).  However, the SQL tags can
support pooling by using, rather than creating, a DataSource.

 2-
 I need read a recorset JSTL with JSP script because the JSTL tag put 
 \n each time I close a tag. I need an output without \n but I like 
 JSTL recorset.
 
 c:set var=language_set value=it /2
 sql:query var=elenco 
 SELECTID_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
 !--
 The follow script don't work. Do you now where path recorset variables are?
 --
 %
 out.print(elenco);
 %

Note first that it's better to be using sql:param and the '?'
placeholder syntax for SQL, rather than using c:out inside
sql:query.  But that doesn't address your problem.

I'm actually not sure what problem you *are* having:  c:out shouldn't
print newlines at the end of its output.  However, when you follow c:out
with a newline (outside the tag), then *that* newline is printed.  But
you'd have the same problem with scriptlets.

Anyway, to answer your specific question, you'd write

 %= pageContext.findAttribute(elenco) %

This is better than out.print(), and it retrieves the scoped attribute via
the PageContext object, which is necessary, for it's not a scripting
variable (just a scoped attribute).

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


--
To unsubscribe, e-mail:   mailto:taglibs-user-unsubscribe;jakarta.apache.org
For additional commands, e-mail: mailto:taglibs-user-help;jakarta.apache.org




Re: jrun jstl

2002-10-30 Thread Shawn Bayern
On Wed, 30 Oct 2002, Lorenzo Sicilia wrote:

 I am a newbie you have some link that explain how to create a
 Datasource with pooling? with JSP is possible or I must use Servlet?

It's a fairly general topic.  Typically, to instantiate a DataSource, you
just use a class that a database vendor provides -- or alternatively a
pooling DataSource that can be layered on top of any driver, as in the
DBCP package from Jakarta Commons at

  http://jakarta.apache.org/commons/dbcp.html

  Note first that it's better to be using sql:param and the '?'
  placeholder syntax for SQL, rather than using c:out inside
  sql:query.  But that doesn't address your problem.

 I now but why is better your solution? Memory usage?

Security.  Using '?' and c:param ensures that any dangerous characters
will be escaped.  By dangerous, I mean characters like a single quote
(') that could alter the sense of your SQL statement and end up hijacking
it to produce unintended results.

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


--
To unsubscribe, e-mail:   mailto:taglibs-user-unsubscribe;jakarta.apache.org
For additional commands, e-mail: mailto:taglibs-user-help;jakarta.apache.org




Re: jrun jstl

2002-10-30 Thread Lorenzo Sicilia
Shawn Bayern wrote:

Anyway, to answer your specific question, you'd write

 %= pageContext.findAttribute(elenco) %



It work fine!

I have tried this:
pageContext.findAttribute(elenco).getRowsByIndex()
the error is:

*** Error: No method named getRows was found in type java/lang/Object.


I need read the fields and colums with a for.

some idea?

tks Lorenzo Sicilia


--
To unsubscribe, e-mail:   mailto:taglibs-user-unsubscribe;jakarta.apache.org
For additional commands, e-mail: mailto:taglibs-user-help;jakarta.apache.org




Re: jrun jstl

2002-10-30 Thread Lorenzo Sicilia
Shawn Bayern wrote:

It's a fairly general topic.  Typically, to instantiate a DataSource, you
just use a class that a database vendor provides -- or alternatively a
pooling DataSource that can be layered on top of any driver, as in the
DBCP package from Jakarta Commons at

  http://jakarta.apache.org/commons/dbcp.html



I use JRUN4 and Mysql.
I have com.mysql.jdbc.Driver OpenSource and org.gjt.mm.mysql.Driver by 
Macromedia.
Are there Class database vendor provides?

with this tag:

sql:setDataSource url=jdbc:mysql://localhost:3306/aostacompany 
driver=org.gjt.mm.mysql.Driver /

It work fine but I think there is not pooling

with this tag:

sql:setDataSource driver=com.mysql.jdbc.Driver dataSource=aosta_db/

It don't work
I receive this error:
javax.servlet.jsp.JspException: Unable to get connection, DataSource 
invalid: No suitable driver

Security.  Using '?' and c:param ensures that any dangerous characters
will be escaped.  By dangerous, I mean characters like a single quote
(') that could alter the sense of your SQL statement and end up hijacking
it to produce unintended results.

Ok, but I think the true problem is about INSERT or DELETE. Select is 
not very dangerous. or no?

Thanks very much.

Lorenzo Sicilia



--
To unsubscribe, e-mail:   mailto:taglibs-user-unsubscribe;jakarta.apache.org
For additional commands, e-mail: mailto:taglibs-user-help;jakarta.apache.org



Re: jrun jstl

2002-10-30 Thread Shawn Bayern
On Wed, 30 Oct 2002, Lorenzo Sicilia wrote:

 I use JRUN4 and Mysql.
 I have com.mysql.jdbc.Driver OpenSource and org.gjt.mm.mysql.Driver by 
 Macromedia.
 Are there Class database vendor provides?

Yes, both of those classes are implementations of the JDBC Driver
interface that come ultimately from the database vendor.  I don't use
MySQL, so I don't know offhand if they produce their own pooling
DataSource.  You can, however, use Jakarta Commons's DBCP.

  Security.  Using '?' and c:param ensures that any dangerous characters
  will be escaped.  By dangerous, I mean characters like a single quote
  (') that could alter the sense of your SQL statement and end up hijacking
  it to produce unintended results.

 Ok, but I think the true problem is about INSERT or DELETE. Select is 
 not very dangerous. or no?

Hijacked SELECT statements can be dangerous if you're concerned about who
gains read-only access to your data.

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


--
To unsubscribe, e-mail:   mailto:taglibs-user-unsubscribe;jakarta.apache.org
For additional commands, e-mail: mailto:taglibs-user-help;jakarta.apache.org




RE: jrun jstl

2002-10-30 Thread ceska
Hello-

I am new to JSTL and JSP, so this may not apply, but I figured I would share anyway.

I use Caucho Resin and do the following:

In my resin.conf:

resource-ref
  res-ref-namejdbc/test/res-ref-name
  res-typejavax.sql.DataSource/res-type
  init-param driver-name=com.caucho.jdbc.mysql.Driver/
  init-param url=jdbc:mysql-caucho://localhost:3306/test/
/resource-ref

in my .jsp page:

sql:setDataSource dataSource=jdbc/test /


Doesn't this seem reasonable?

-chris

-Original Message-
From: Lorenzo Sicilia [mailto:arnor;kemen.it] 
Sent: Wednesday, October 30, 2002 11:28 AM
To: Tag Libraries Users List
Subject: Re: jrun  jstl

Shawn Bayern wrote:
 It's a fairly general topic.  Typically, to instantiate a DataSource, you
 just use a class that a database vendor provides -- or alternatively a
 pooling DataSource that can be layered on top of any driver, as in the
 DBCP package from Jakarta Commons at
 
   http://jakarta.apache.org/commons/dbcp.html
 

I use JRUN4 and Mysql.
I have com.mysql.jdbc.Driver OpenSource and org.gjt.mm.mysql.Driver by 
Macromedia.
Are there Class database vendor provides?

with this tag:

sql:setDataSource url=jdbc:mysql://localhost:3306/aostacompany 
driver=org.gjt.mm.mysql.Driver /

It work fine but I think there is not pooling

with this tag:

sql:setDataSource driver=com.mysql.jdbc.Driver dataSource=aosta_db/

It don't work
I receive this error:
javax.servlet.jsp.JspException: Unable to get connection, DataSource 
invalid: No suitable driver

 Security.  Using '?' and c:param ensures that any dangerous characters
 will be escaped.  By dangerous, I mean characters like a single quote
 (') that could alter the sense of your SQL statement and end up hijacking
 it to produce unintended results.
Ok, but I think the true problem is about INSERT or DELETE. Select is 
not very dangerous. or no?

Thanks very much.

Lorenzo Sicilia



--
To unsubscribe, e-mail:   mailto:taglibs-user-unsubscribe;jakarta.apache.org
For additional commands, e-mail: mailto:taglibs-user-help;jakarta.apache.org

--
To unsubscribe, e-mail:   mailto:taglibs-user-unsubscribe;jakarta.apache.org
For additional commands, e-mail: mailto:taglibs-user-help;jakarta.apache.org




Re: jrun jstl

2002-10-30 Thread Shawn Bayern
On Wed, 30 Oct 2002, Lorenzo Sicilia wrote:

 sorry but I am very newbie :o)
 
 my script:
 
 %
   ResultSet pippo = (ResultSet) pageContext.findAttribute(elenco);
   out.print(pippo.getRows());
 %
 
 it don't work. The problem is the cast. the error is:
 
 
 411.  ResultSet pippo = (ResultSet) pageContext.findAttribute(elenco);
   ^---^
 *** Error: Type ResultSet was not found.

First, you either need to qualify the class's name with a package or %
page import=... % the right package.  Second, you don't really mean
ResultSet in this case; you're referring to a JSTL Result.  Thus, if you
*must* use a scriptlet -- and I still fail to see what it's doing for you
that the JSTL tags aren't -- then you can write

 % page import=javax.servlet.jsp.jstl.sql.Result %
 ...
 %
Result pippo = (Result) ...;
...
 %

I strongly recommend not doing this, though, and using the JSTL tags
instead.  The issue you noted with line breaks will affect you with
scriptlets as much as it will with JSTL tags.

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


--
To unsubscribe, e-mail:   mailto:taglibs-user-unsubscribe;jakarta.apache.org
For additional commands, e-mail: mailto:taglibs-user-help;jakarta.apache.org