How to maintain collections with JSTL?

2002-11-15 Thread Zaretzke, Peter
Dear friends of JSTL

I'm new to JSTL and looking for some ideas how to maintain collections with
JSTL and EL.

I have a bean with a List and a Map type property like this:

public class TestBean  {
private List list = new ArrayList();
private Map map = new HashMap();

public TestBean () {
list.add(initial value 1);
list.add(initial value 2);
map.put (simple value,the initial simple value);
map.put (listvalue, list );
}

public List getList() {
return list;
}

public Map getMap() {
return map;
}   
}


Getting the values from my collections is easy and elegant:

c:forEach var=litem items=${testbean.listitems} 
  c:out value=${litem}/br/
/c:forEach

c:forEach var=mitem items=${testbean.map} 
  c:out value=${mitem.key}/ = c:out
value=${mitem.value}/br/
/c:forEach

But how to add a new items to the collections? I tried this

c:set target=${testbean} property=list value=${myvalue}/

But this bean method 

public void setList( String value ) {
list.add ( value );
}

does not work because it does not meet the parameter expectations ( List vs.
String ) for beans.
I know that I can write more setZZZ() methods to add something to the List
but it breaks somehow the naming conventions for beans (getXxx, setXxx). And
how to add a new entry to the map? 


Thanks in advance
Peter

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




Re: How to maintain collections with JSTL?

2002-11-15 Thread Shawn Bayern
On Fri, 15 Nov 2002, Zaretzke, Peter wrote:

   public void setList( String value ) {
   list.add ( value );
   }
 
 does not work because it does not meet the parameter expectations (
 List vs. String ) for beans. I know that I can write more setZZZ()
 methods to add something to the List but it breaks somehow the naming
 conventions for beans (getXxx, setXxx). And how to add a new entry to
 the map?

Unless you're happy with writing a new setXxx() method that modifies a
collection (which is a clever idea but still something of a hack because
it violates the intent of the JavaBeans specification), it's actually
quite hard to manage collections in this way with JSTL.  Since JSTL is
focused on presentation -- on reading data structures rather than writing
them -- it's likely going to be easier to modify collections in a back-end
servlet (or with a new custom tag you write -- one that's specific to your
own custom data).

Shawn


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




Re: Jakarta Mailer

2002-11-15 Thread Glenn Nielsen
The Mailer taglib does not support the EL at this time.  Supporting the EL
will require changes to the taglib.

Second, you can either hardcode attributes such as to, from, etc. in the mail
tag itself. Or you can set them dynamically by nesting the mt:setrecipient tag inside
the mt:mail tag.  The mailer taglib example and docs show how to do this.

Regards,

Glenn

Stefan wrote:

Hi,

Did the following and it does not work:

%@ taglib uri=http://jakarta.apache.org/taglibs/mailer-1.0; prefix=mt %
%@ taglib prefix='c_rt' uri='http://java.sun.com/jstl/core_rt' %
%@ taglib prefix='c' uri='http://java.sun.com/jstl/core' %

%
String from_ = [EMAIL PROTECTED];
String to_ = [EMAIL PROTECTED];
%

/head

body
h2Jakarta Mail Works Great!/h2
c_rt:set var=to scope=session value=%= to_ %/

mt:mail server=mail.lonewolfe.com to=c:out value='${to}'/
from=[EMAIL PROTECTED] subject=Jakarta mail taglib
mt:message type=html


Thanks,

Stef



- Original Message -
From: Mark Goking [EMAIL PROTECTED]
To: Tag Libraries Users List [EMAIL PROTECTED]
Sent: Thursday, November 14, 2002 10:44 PM
Subject: RE: Jakarta Mailer



if you say that it doesnt work then put those variables in a c:set
var=from value=%= from_ %/

or
c:set varfrom
%= from_ %
/c:set

mark


-Original Message-
From: Stefan [mailto:nickm;studioweb.com]
Sent: Friday, November 15, 2002 11:16 AM
To: Tag Libraries Users List
Subject: Re: Jakarta Mailer


Hi,

This works:

%@ taglib uri=http://jakarta.apache.org/taglibs/mailer-1.0; prefix=mt %

mt:mail server=mail.lonewolfe.com to=[EMAIL PROTECTED]
from=[EMAIL PROTECTED] subject=Jakarta mail taglib
mt:message type=html


- And this  does not work for me, perhaps you can see why:


%@ taglib uri=http://jakarta.apache.org/taglibs/mailer-1.0; prefix=mt %

%
String from_ = [EMAIL PROTECTED];
String to_ = [EMAIL PROTECTED];
%

/head

body
h2Jakarta Mail Works Great!/h2


mt:mail server=mail.lonewolfe.com to=%= to_ % from=%= from_ %
subject=Jakarta mail taglib
mt:message type=html




- Original Message -
From: Mark Goking [EMAIL PROTECTED]
To: Tag Libraries Users List [EMAIL PROTECTED]
Sent: Thursday, November 14, 2002 10:10 PM
Subject: RE: Jakarta Mailer



stefan, that works. maybe you have other code problems that resulted in that
not working.
you can use %= % inside  but not inside ${}

mark

-Original Message-
From: Stefan [mailto:nickm;studioweb.com]
Sent: Friday, November 15, 2002 11:07 AM
To: Tag Libraries Users List
Subject: Jakarta Mailer


Hi,

I want to be able to pass dynamic values for some the the taglibs
attributes:

mt:mail server=mail.lonewolfe.com to=%= to % from=%= from %
subject=Jakarta mail taglib

This does not seem to work, is this a context issue? If so would using JSTL
${param.parameterName} work or c:set ?

Thanks,

Stef

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.410 / Virus Database: 231 - Release Date: 10/31/2002


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.410 / Virus Database: 231 - Release Date: 10/31/2002


--
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


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.410 / Virus Database: 231 - Release Date: 10/31/2002


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.410 / Virus Database: 231 - Release Date: 10/31/2002


--
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





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




Re: How to maintain collections with JSTL?

2002-11-15 Thread Hans Bergsten
Zaretzke, Peter wrote:

[...]
But how to add a new items to the collections? I tried this

	c:set target=${testbean} property=list value=${myvalue}/

But this bean method 

	public void setList( String value ) {
		list.add ( value );
	}

does not work because it does not meet the parameter expectations ( List vs.
String ) for beans.
I know that I can write more setZZZ() methods to add something to the List
but it breaks somehow the naming conventions for beans (getXxx, setXxx). And
how to add a new entry to the map? 

It should work as long as the value can be converted to a String (which
is almost always the case, see the EL type coersion rules). What kind of
error do you see? If you want to avoid convertion to String, change the
setList() method to take an Object instead of a String.

Hans
--
Hans Bergsten[EMAIL PROTECTED]
Gefion Software   http://www.gefionsoftware.com/
Author of O'Reilly's JavaServer Pages, covering JSP 1.2 and JSTL 1.0
Details athttp://TheJSPBook.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: Jakarta Mailer

2002-11-15 Thread Stefan
Hi,

Thans for the info. I will spend a bit more time reading the docs next time!

BTW: I found that it atleast supports some EL. I was able to use c:out and
it took.

If I wanted to reference an attached image file in the html portion of the
mail so that it would appear in the layout how would I do this?

Thanks,

Stef


- Original Message -
From: Glenn Nielsen [EMAIL PROTECTED]
To: Tag Libraries Users List [EMAIL PROTECTED]
Sent: Friday, November 15, 2002 8:28 AM
Subject: Re: Jakarta Mailer


 The Mailer taglib does not support the EL at this time.  Supporting the EL
 will require changes to the taglib.

 Second, you can either hardcode attributes such as to, from, etc. in the
mail
 tag itself. Or you can set them dynamically by nesting the
mt:setrecipient tag inside
 the mt:mail tag.  The mailer taglib example and docs show how to do
this.

 Regards,

 Glenn

 Stefan wrote:
  Hi,
 
  Did the following and it does not work:
 
  %@ taglib uri=http://jakarta.apache.org/taglibs/mailer-1.0;
prefix=mt %
  %@ taglib prefix='c_rt' uri='http://java.sun.com/jstl/core_rt' %
  %@ taglib prefix='c' uri='http://java.sun.com/jstl/core' %
 
  %
  String from_ = [EMAIL PROTECTED];
  String to_ = [EMAIL PROTECTED];
  %
 
  /head
 
  body
  h2Jakarta Mail Works Great!/h2
  c_rt:set var=to scope=session value=%= to_ %/
 
  mt:mail server=mail.lonewolfe.com to=c:out value='${to}'/
  from=[EMAIL PROTECTED] subject=Jakarta mail taglib
  mt:message type=html
 
 
  Thanks,
 
  Stef
 
 
 
  - Original Message -
  From: Mark Goking [EMAIL PROTECTED]
  To: Tag Libraries Users List [EMAIL PROTECTED]
  Sent: Thursday, November 14, 2002 10:44 PM
  Subject: RE: Jakarta Mailer
 
 
 
  if you say that it doesnt work then put those variables in a c:set
  var=from value=%= from_ %/
 
  or
  c:set varfrom
  %= from_ %
  /c:set
 
  mark
 
 
  -Original Message-
  From: Stefan [mailto:nickm;studioweb.com]
  Sent: Friday, November 15, 2002 11:16 AM
  To: Tag Libraries Users List
  Subject: Re: Jakarta Mailer
 
 
  Hi,
 
  This works:
 
  %@ taglib uri=http://jakarta.apache.org/taglibs/mailer-1.0;
prefix=mt %
 
  mt:mail server=mail.lonewolfe.com to=[EMAIL PROTECTED]
  from=[EMAIL PROTECTED] subject=Jakarta mail taglib
  mt:message type=html
 
 
  - And this  does not work for me, perhaps you can see why:
 
 
  %@ taglib uri=http://jakarta.apache.org/taglibs/mailer-1.0;
prefix=mt %
 
  %
  String from_ = [EMAIL PROTECTED];
  String to_ = [EMAIL PROTECTED];
  %
 
  /head
 
  body
  h2Jakarta Mail Works Great!/h2
 
 
  mt:mail server=mail.lonewolfe.com to=%= to_ % from=%= from_ %
  subject=Jakarta mail taglib
  mt:message type=html
 
 
 
 
  - Original Message -
  From: Mark Goking [EMAIL PROTECTED]
  To: Tag Libraries Users List [EMAIL PROTECTED]
  Sent: Thursday, November 14, 2002 10:10 PM
  Subject: RE: Jakarta Mailer
 
 
 
  stefan, that works. maybe you have other code problems that resulted in
that
  not working.
  you can use %= % inside  but not inside ${}
 
  mark
 
  -Original Message-
  From: Stefan [mailto:nickm;studioweb.com]
  Sent: Friday, November 15, 2002 11:07 AM
  To: Tag Libraries Users List
  Subject: Jakarta Mailer
 
 
  Hi,
 
  I want to be able to pass dynamic values for some the the taglibs
  attributes:
 
  mt:mail server=mail.lonewolfe.com to=%= to % from=%= from %
  subject=Jakarta mail taglib
 
  This does not seem to work, is this a context issue? If so would using
JSTL
  ${param.parameterName} work or c:set ?
 
  Thanks,
 
  Stef
 
  ---
  Incoming mail is certified Virus Free.
  Checked by AVG anti-virus system (http://www.grisoft.com).
  Version: 6.0.410 / Virus Database: 231 - Release Date: 10/31/2002
 
 
  ---
  Outgoing mail is certified Virus Free.
  Checked by AVG anti-virus system (http://www.grisoft.com).
  Version: 6.0.410 / Virus Database: 231 - Release Date: 10/31/2002
 
 
  --
  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
 
 
  ---
  Incoming mail is certified Virus Free.
  Checked by AVG anti-virus system (http://www.grisoft.com).
  Version: 6.0.410 / Virus Database: 231 - Release Date: 10/31/2002
 
 
  ---
  Outgoing mail is certified Virus Free.
  Checked by AVG anti-virus system (http://www.grisoft.com).
  Version: 6.0.410 / Virus Database: 231 - Release Date: 10/31/2002
 
 
  --
  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




 --
 To unsubscribe, e-mail:

Re: Jakarta Mailer

2002-11-15 Thread Henri Yandell


On Fri, 15 Nov 2002, Stefan wrote:

 Hi,

 Thans for the info. I will spend a bit more time reading the docs next time!

 BTW: I found that it atleast supports some EL. I was able to use c:out and
 it took.

Yeah, usually no-EL support means that the hack for Jakarta Standard
taglib hasn't been put in so that the attributes in the taglib can use the
${...}.

Apart from this, I think all taglibs should work with JSTL.

Hen


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




JSTL, core library - url for mail

2002-11-15 Thread Gisella Saavedra
I have the following piece of code in a .jsp file for having a link to send e-mail.
The code rendered as .html has + as blank spaces for the
mail Subject (TBS+-+An+unexpected+error+has+occurred). 

Any idea how I can get regular spaces?
[I have tried nbsp; \u20
 an I get the value as typed.]


a href=mailto:c:url  value=${applicationScope.supportEMail} 
   c:param name=Subject value=TBS - An unexpected error has 
occurred /
   /c:urlDev. Team/a.


Regards,

Gisella



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




problem with SQL tags

2002-11-15 Thread John C Cartwright
Hello All,

I am hoping that someone can help me to get going with the SQL tags. 
I'm trying to connect to a mysql database using tomcat4.1.12 and version 
1.0.2 of the library.

Here's my JSP:

%@ taglib prefix=sql uri=http://java.sun.com/jstl/sql; %
%@ taglib prefix=c uri=http://java.sun.com/jstl/core; %

HTML
HEAD
/HEAD
BODY
sql:setDataSource var=monitorDS
   url=jdbc:mysql://myhost.noaa.gov:3306/testdb
   driver=org.gjt.mm.mysql.Driver
   user=testuser
   password=testpass
/
/BODY
/HTML

I'm getting a:
org.apache.jasper.JasperException: Unable to get connection, DataSource 
invalid: No suitable driver

exception thrown even though a very similar JSP using standard JDBC 
connection methods (listed below) works fine.

Connection con;
try {
   Class.forName(org.gjt.mm.mysql.Driver);
   con = 
DriverManager.getConnection(jdbc:mysql://myhost.noaa.gov:3306/testdb,testuser,testpass);
   } catch (Exception e) {
  throw (new ServletException(Error loading Driver:  
+e.getMessage()));
   }



Can someone help me?

Thanks!


-- john

=
John Cartwright
Associate Scientist
Geospatial Data Services Group
CIRES, National Geophysical Data Center/NOAA
(303) 497-6284
[EMAIL PROTECTED]
=



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



fmt:setLocale value=es

2002-11-15 Thread Paul Campbell

It seems that if I specify a Locale(es) for the first invocation of a jsp,
I will get the appropriate output. Spanish Text for labels and headings.

However, if I access the same page with a different Locale(en) from
another browser, I still get the same output in Spanish.

It appears that the format applies at compile time rather than run time
even though I specify scope as page instead of session, both
give same result.

I base this on trying this where I have run a Mozilla as Locale(en ) and
on second machine accessed the same page with IE as Locale(es) or
Mozilla on second machine also as Locale(es) only.
The access from the second machine has zero latency before it sends back the page.

Is my understanding faulty? 

If this behavior is correct, then this capability for internationalization
means which ever language gets compiled first wins?

(I restarted the mozilla and ie after I changed the Locales.)

% page contentType=text/html %
% taglib prefix=c   uri=http://java.sun.com/jstl/core; %
% taglib prefix=fmt uri=http://java.sun.com/jstl/fmt; %
c:if test=${param.language == 'en'}
fmt:setLocale value=en scope=page /
/c:if
c:if test=${param.language == 'es'}
fmt:setLocale value=es scope=page /
/c:if
fmt:setBundle basename=sitetext scope=page /


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




Re: problem with SQL tags

2002-11-15 Thread Hans Bergsten
John C Cartwright wrote:

Hello All,

I am hoping that someone can help me to get going with the SQL tags. I'm 
trying to connect to a mysql database using tomcat4.1.12 and version 
1.0.2 of the library.

Here's my JSP:

%@ taglib prefix=sql uri=http://java.sun.com/jstl/sql; %
%@ taglib prefix=c uri=http://java.sun.com/jstl/core; %

HTML
HEAD
/HEAD
BODY
sql:setDataSource var=monitorDS
   url=jdbc:mysql://myhost.noaa.gov:3306/testdb
   driver=org.gjt.mm.mysql.Driver
   user=testuser
   password=testpass
/
/BODY
/HTML

I'm getting a:
org.apache.jasper.JasperException: Unable to get connection, DataSource 
invalid: No suitable driver

This is because the JDBC driver classes are not found by the web
container. Make sure you have installed them in the WEB-INF/lib
directory of the application.

 [...]

Hans
--
Hans Bergsten[EMAIL PROTECTED]
Gefion Software   http://www.gefionsoftware.com/
Author of O'Reilly's JavaServer Pages, covering JSP 1.2 and JSTL 1.0
Details athttp://TheJSPBook.com/


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