escape tag
Is there a mode to reverse escape a string after the tag str:escapesomething/str:escape? I have to remove some char (\r\n) and then un-escape all the other special chars. Thank you again. Andrea Grittini ( mailto:[EMAIL PROTECTED]) Tel: +39-2-97482.1- Fax: +39-2-97482? Computer Design S.r.l., Via Piave 46 - 20010 S.Stefano Ticino - ITALY http://www.cdesign.it/
standard sql param tag
I used sql:query .../ to retrieve timestamp date which is like 2002-04-21 22:09:48.0 What I would like to show the date. How to use fmt:parseDate value=${row.myDate} to get only date part or time part. Thanks Alcie _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
dbtags: How do I use the results to create a link?
Hi, I am using the dbtags library to query a database. I am getting a resultset and I would like to create a link to another page that contains the value of a database cell as a parameter. The code looks like this: sql:statement id=stmt1 conn=conn1 sql:query select id, description from COLORS order by id /sql:query %-- loop through the rows of your query --% sql:resultSet id=rset2 tr tdsql:getColumn position=1//td td a href=details.jsp?colorId=*insert value of 1st getColumn here* Details about sql:getColumn position=2/ /a /td /tr /sql:resultSet /sql:statement The output should look like this: 1 Details about red 2 Details about green 3 Details about blue where red, green and blue would be clickable links to details.jsp?colorId=1, details.jsp?colorId=2, details.jsp?colorId=3 and so on. How should I code this? Tnx... Matthias Bohlen -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Standard Query Blob or Memo field
How to retrieve the actual memo/blob field in a query When I try c:out value=${row.msg}/ I got org.firebirdsql.jdbc.FBBlob@12dd76 instend of the actual String. How to convert into String? Alice _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: standard sql param tag
On Tue, 23 Apr 2002, Alice K wrote: I used sql:query .../ to retrieve timestamp date which is like 2002-04-21 22:09:48.0 What I would like to show the date. How to use fmt:parseDate value=${row.myDate} to get only date part or time part. I think you're looking for fmt:formatDate, not fmt:parseDate. -- Shawn Bayern JSP Standard Tag Library http://www.jstlbook.com (coming this summer from Manning Publications) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: c:if puzzle
The Fix, FYI ... I upgraded to Resin 2.1.0 from Resin 2.0.5 and the problem resolved itself... c:if test=${1==0} P*** Found with JSTL!/P /c:if Returned true in Resin 2.0.5 In 2.1.0 things work as expected... Thanks for the thoughts and suggestions on the matter -emc -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Nesting tags from different tag libraries?
On Tue, 23 Apr 2002 [EMAIL PROTECTED] wrote: Since JSTL doesn't do anything more than more or less writing stuff into a HTML page, I looked at the possibility of using another tag library for string manipulation. The String Tag library looks excellent. However, I'm not sure if something like this would work: str:substring start=1 end=10 c:out value=${someText}/ /str:substring At what point does the starting tag get the contained body? Will it only get the JSTL tag or will it get the content of the JSTL tag? The first case of course wouldn't help... Yes - JSP tags within other JSP tags get evaluated by the container as usual (and so your example will work) when the outer tag is declared as having a body type of JSP (versus tagdependent) in its TLD. -- Shawn Bayern JSP Standard Tag Library http://www.jstlbook.com (coming this summer from Manning Publications) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Nesting tags from different tag libraries?
Hi Eric, It should work. I'm trying to work hard at making the String tag library integrate as much as possible with JSTL as it seems to be the most common place it gets used now. For example, I've copied the JSTL habit of being able to place all output into a var variable, and there's a StringTagSupport class there if you want to write your own string-based tags. Basically, if your example doesn't work for you, then it'll get fixed pronto. However the way these things work is that the substring tag should get the output of the c:out tag and not the tag itself. Someone found a bug in this a week or so back, [the string taglibs fault] so you might need to grab the latest jar file. Hen On Tue, 23 Apr 2002 [EMAIL PROTECTED] wrote: Hi Since JSTL doesn't do anything more than more or less writing stuff into a HTML page, I looked at the possibility of using another tag library for string manipulation. The String Tag library looks excellent. However, I'm not sure if something like this would work: str:substring start=1 end=10 c:out value=${someText}/ /str:substring At what point does the starting tag get the contained body? Will it only get the JSTL tag or will it get the content of the JSTL tag? The first case of course wouldn't help... Best regards, Eric swissinfo/Swiss Radio International Eric Lewis IT Engineering Giacomettistrasse 1 CH-3000 Berne 15 Phone:++41 31 350 95 42 Fax: ++41 31 350 99 40 mailto:[EMAIL PROTECTED] Switzerland is everywhere. Stay connected! http://www.swissinfo.org http://mobile.swissinfo.org http:/wap.swissinfo.org SRG SSR idée suisse -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Nesting tags from different tag libraries?
On Tue, 23 Apr 2002, Shawn Bayern wrote: Yes - JSP tags within other JSP tags get evaluated by the container as usual (and so your example will work) when the outer tag is declared as having a body type of JSP (versus tagdependent) in its TLD. All the string taglib body types are JSP by the way. I'd love to take credit, but I hadn't known there was another option :) Hen -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
How to test on not empty
Hi I was just wondering while reading the specification - how do I test on something being not empty? c:if test=${!empty param.name} You specified a name. /c:if Is this correct? Regards, Eric -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: How to test on not empty
On Tue, 23 Apr 2002 [EMAIL PROTECTED] wrote: I was just wondering while reading the specification - how do I test on something being not empty? c:if test=${!empty param.name} You specified a name. /c:if Is this correct? Sure - or ${not empty param.name} -- Shawn Bayern JSP Standard Tag Library http://www.jstlbook.com (coming this summer from Manning Publications) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Off-topic: Thanks!
Well... I know this is kinda off-topic, but still... From what I've seen till now, all developers are being really very helpful (I mean, until now I only dealed with Shawn, and like you he's damn quick in responding!). Just wanted to say a big THANK YOU! :-) If only other companies I won't mention here (but we all know them...) were like that... Regards, Eric -Original Message- From: Henri Yandell [mailto:[EMAIL PROTECTED]] Sent: Dienstag, 23. April 2002 17:00 To: Tag Libraries Users List Subject: Re: Nesting tags from different tag libraries? On Tue, 23 Apr 2002, Shawn Bayern wrote: Yes - JSP tags within other JSP tags get evaluated by the container as usual (and so your example will work) when the outer tag is declared as having a body type of JSP (versus tagdependent) in its TLD. All the string taglib body types are JSP by the way. I'd love to take credit, but I hadn't known there was another option :) Hen -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: How to test on not empty
--- Shawn Bayern [EMAIL PROTECTED] wrote: On Tue, 23 Apr 2002 [EMAIL PROTECTED] wrote: I was just wondering while reading the specification - how do I test on something being not empty? c:if test=${!empty param.name} You specified a name. /c:if Is this correct? Sure - or ${not empty param.name} or ${param.name != null} = Morgan Delagrange http://jakarta.apache.org/taglibs http://jakarta.apache.org/commons http://axion.tigris.org __ Do You Yahoo!? Yahoo! Games - play chess, backgammon, pool and more http://games.yahoo.com/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Nesting tags from different tag libraries?
Ok, I now installed the String Tag Library, and it works fine on its own. I installed it into my JSTL directory C:\Program Files\Apache Tomcat 4.0\webapps\jstl\ and put the *.war into C:\Program Files\Apache Tomcat 4.0\webapps\ (where I also put the JSTL standard-examples.war). So now I can use the JSTL examples from http://localhost:8080/standard-examples/index.html and I can use the String Tag exmples from http://localhost:8080/string-examples/index.html - everything works fine. However, I tried modifying the Iterator example http://localhost:8080/standard-examples/iterators/Simple.jsp to include String tags, i.e. the first lines read %@ taglib prefix=c uri=http://java.sun.com/jstl/ea/core; % %@ taglib prefix=str uri=http://jakarta.apache.org/taglibs/string-1.0; % (I didn't write String tags yet, since I always take baby steps...) and it crashes: org.apache.jasper.JasperException: This absolute uri (http://jakarta.apache.org/taglibs/string-1.0) cannot be resolved in either web.xml or the jar files deployed with this application at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:194) at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:174) at org.apache.jasper.compiler.JspParseEventListener.processTaglibDirective(JspP arseEventListener.java:1162) at org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEve ntListener.java:758) at org.apache.jasper.compiler.DelegatingListener.handleDirective(DelegatingList ener.java:121) etc. etc. Is there anything blindingly stupid I did wrong? ;-) Regards, Eric -Original Message- From: Shawn Bayern [mailto:[EMAIL PROTECTED]] Sent: Dienstag, 23. April 2002 16:57 To: Tag Libraries Users List Subject: Re: Nesting tags from different tag libraries? On Tue, 23 Apr 2002 [EMAIL PROTECTED] wrote: Since JSTL doesn't do anything more than more or less writing stuff into a HTML page, I looked at the possibility of using another tag library for string manipulation. The String Tag library looks excellent. However, I'm not sure if something like this would work: str:substring start=1 end=10 c:out value=${someText}/ /str:substring At what point does the starting tag get the contained body? Will it only get the JSTL tag or will it get the content of the JSTL tag? The first case of course wouldn't help... Yes - JSP tags within other JSP tags get evaluated by the container as usual (and so your example will work) when the outer tag is declared as having a body type of JSP (versus tagdependent) in its TLD. -- Shawn Bayern JSP Standard Tag Library http://www.jstlbook.com (coming this summer from Manning Publications) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Nesting tags from different tag libraries?
Making symlinks to the .jar files works too. e.g. (we're talking unix/linux/MacOS X here): while inside /usr/java/tomcat/webapps/foo/WEB-INF/lib ln -s /usr/java/jakarta-taglibs/standard/standard.jar standard.jar This is REALLY important, because each time I upgrade to a new version of the taglibs, I only need to update the one in /usr/java/jakarta-taglibs/. Whereas if I copied the file to all the different foo|bar|blort/WEB-INF directories, I'd have to replace about twelve different files. symlinks are your friend (I am sure Windows users can make a shortcut). -c On Tue, 23 Apr 2002, Shawn Bayern wrote: Eric, You need to install the individaul JAR files for all taglibs you want to use (e.g., standard.jar jstl.jar, or string.jar) in the WEB-INF/lib directory of your web application. Once you've done that, your container should recognize the tag libraries. Tomcat 4.0.3 has a bug whereby it doesn't recognize them by default unless you modify your web.xml file, but Ryan Lubke posted a workaround yesterday (And you can also upgrade to Tomcat 4.0.4B2). -- Shawn Bayern JSP Standard Tag Library http://www.jstlbook.com (coming this summer from Manning Publications) On Tue, 23 Apr 2002 [EMAIL PROTECTED] wrote: Ok, I now installed the String Tag Library, and it works fine on its own. I installed it into my JSTL directory C:\Program Files\Apache Tomcat 4.0\webapps\jstl\ and put the *.war into C:\Program Files\Apache Tomcat 4.0\webapps\ (where I also put the JSTL standard-examples.war). So now I can use the JSTL examples from http://localhost:8080/standard-examples/index.html and I can use the String Tag exmples from http://localhost:8080/string-examples/index.html - everything works fine. However, I tried modifying the Iterator example http://localhost:8080/standard-examples/iterators/Simple.jsp to include String tags, i.e. the first lines read %@ taglib prefix=c uri=http://java.sun.com/jstl/ea/core; % %@ taglib prefix=str uri=http://jakarta.apache.org/taglibs/string-1.0; % (I didn't write String tags yet, since I always take baby steps...) and it crashes: org.apache.jasper.JasperException: This absolute uri (http://jakarta.apache.org/taglibs/string-1.0) cannot be resolved in either web.xml or the jar files deployed with this application at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:194) at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:174) at org.apache.jasper.compiler.JspParseEventListener.processTaglibDirective(JspP arseEventListener.java:1162) at org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEve ntListener.java:758) at org.apache.jasper.compiler.DelegatingListener.handleDirective(DelegatingList ener.java:121) etc. etc. Is there anything blindingly stupid I did wrong? ;-) Regards, Eric -Original Message- From: Shawn Bayern [mailto:[EMAIL PROTECTED]] Sent: Dienstag, 23. April 2002 16:57 To: Tag Libraries Users List Subject: Re: Nesting tags from different tag libraries? On Tue, 23 Apr 2002 [EMAIL PROTECTED] wrote: Since JSTL doesn't do anything more than more or less writing stuff into a HTML page, I looked at the possibility of using another tag library for string manipulation. The String Tag library looks excellent. However, I'm not sure if something like this would work: str:substring start=1 end=10 c:out value=${someText}/ /str:substring At what point does the starting tag get the contained body? Will it only get the JSTL tag or will it get the content of the JSTL tag? The first case of course wouldn't help... Yes - JSP tags within other JSP tags get evaluated by the container as usual (and so your example will work) when the outer tag is declared as having a body type of JSP (versus tagdependent) in its TLD. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Carole E. Mah [EMAIL PROTECTED] Senior Programmer/Analyst Brown University Scholarly Technology Group phn 401-863-2669 fax 401-863-9313 http://www.stg.brown.edu/ personal: http://www.stg.brown.edu/~carolem/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Nesting tags from different tag libraries?
On Tue, 23 Apr 2002, Carole E. Mah wrote: This is REALLY important, because each time I upgrade to a new version of the taglibs, I only need to update the one in /usr/java/jakarta-taglibs/. Whereas if I copied the file to all the different foo|bar|blort/WEB-INF directories, I'd have to replace about twelve different files. Indeed. I often symlink entire application directories because I switch containers as often as I upgrade tag libraries. :-) symlinks are your friend (I am sure Windows users can make a shortcut). No, that won't work on Windows, but it's a little-known fact that Window's NFTS filesystem indeed supports *hard* links, just like Unix does. You typically need a tool from Microsoft's Resource Kit to set them up, though; there isn't an interface that's more readily available. -- Shawn Bayern JSP Standard Tag Library http://www.jstlbook.com (coming this summer from Manning Publications) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
getColumn
I don't understand how to use the to attribute. % String myValue = request.getParameter(bar); % sql:getColumn colName=blort to=myValue This is the sort of thing I want to do, I think. But it does not work, i.e. the string foo has a value bar and that ought to get written over by the value of colName blort but it does not. Basically what I want is to get each row value of the 'blort' column from my blah DBtable, and write that to an option value. In PHP, this would be: $query = SELECT farble, blort FROM blah; $my_result = mysql_db_query ($dbname, $query, $linkid); echo select name=\whatever\; while ($my_row =mysql_fetch_object($my_result)) { $myValue = $my_row-blort; echo option value=\$myValue\$myValue/option } echo /select; Clearly to writes somewhere other than a scriplet variable. ?? I am not very smart today. Thanks for any advice, -Carole - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Carole E. Mah [EMAIL PROTECTED] Senior Programmer/Analyst Brown University Scholarly Technology Group phn 401-863-2669 fax 401-863-9313 http://www.stg.brown.edu/ personal: http://www.stg.brown.edu/~carolem/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: getColumn
Yes, the to attribute of the getColumn tag writes to a Servlet attribute, not a scripting variable. A scripting variable would have been awkward because the to attribute is optional; by default the tag will simply write to the current writer. - Original Message - From: Carole E. Mah [EMAIL PROTECTED] To: Tag Libraries Users List [EMAIL PROTECTED] Sent: Tuesday, April 23, 2002 1:35 PM Subject: getColumn I don't understand how to use the to attribute. % String myValue = request.getParameter(bar); % sql:getColumn colName=blort to=myValue This is the sort of thing I want to do, I think. But it does not work, i.e. the string foo has a value bar and that ought to get written over by the value of colName blort but it does not. Basically what I want is to get each row value of the 'blort' column from my blah DBtable, and write that to an option value. In PHP, this would be: $query = SELECT farble, blort FROM blah; $my_result = mysql_db_query ($dbname, $query, $linkid); echo select name=\whatever\; while ($my_row =mysql_fetch_object($my_result)) { $myValue = $my_row-blort; echo option value=\$myValue\$myValue/option } echo /select; Clearly to writes somewhere other than a scriplet variable. ?? I am not very smart today. Thanks for any advice, -Carole - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Carole E. Mah [EMAIL PROTECTED] Senior Programmer/Analyst Brown University Scholarly Technology Group phn 401-863-2669 fax 401-863-9313 http://www.stg.brown.edu/ personal: http://www.stg.brown.edu/~carolem/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: integrating dbtags into MM Ultradev code
Tony, I think there are other members more authorized than me to answer this, but I think you should install CTLX (look for custom extensions in the Jakarta Taglibs). This will install an extension to the ultradev tool, and a servlet in your app server. Then you would insert and manage your custom tags (like escapeSQL or struts or any other) from Ultradev, see the documentation it comes with a tutorial. Beware if the version is of April 19 the servlet doesn´t work, I had to recompile it, I didn´t check the repository, send me a email and I will send you the good servlet. regards, [EMAIL PROTECTED] --- tony [EMAIL PROTECTED] escribió: Hello, Just beginning on java I am wondering how do I integrate the escapeSQL tag from the dbtags package into Macromedia Ultradev generated JSP code. TIA Tony Grant -- RedHat Linux on Sony Vaio C1XD/S http://www.animaproductions.com/linux2.html Macromedia UltraDev with PostgreSQL http://www.animaproductions.com/ultra.html -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] = Colaborativa.net SRL Argentina Email: [EMAIL PROTECTED] _ Do You Yahoo!? Información de Estados Unidos y América Latina, en Yahoo! Noticias. Visítanos en http://noticias.espanol.yahoo.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
taglibs scope
Hi, I have a variable that would be used globally all over an application, c:set var=myGlobalVar scope=...Something/c:set and I put this code in 2 files a.jsp and b.jsp. What will happen if I use 'application' as the scope value? Once myGlobalVar is set in a.jsp, what will happen when the same exact code is encountered in b.jsp? Will it rewrite and overwrite the old myGlobalVar? or will it ignore the rewriting of the same myGlobalVar since myGlobalVar is already set with application scope? And will it behave differently if I set the scope as 'page' in the same scenario? TIA, = Cliffano Subagio http://messenger.yahoo.com.au - Yahoo! Messenger - A great way to communicate long-distance for FREE! -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
c:forEach compared to logic:iterate
I'm using the logic:iterate tag in the following manner: logic:iterate id=pageInfo name=topicForm property=pages html:link forward=getPage name=pageInfo property=pageTopicMap title=%=((PageForm)pageInfo).getName()% c:out value=${pageInfo.pageSequence + 1}/ /html:link /logic:iterate Which works great! However, I was hoping to migrate my logic tags to JSTL and the following doesn't work: c:forEach var=pageInfo items=${topicForm.pages} html:link forward=getPage name=pageInfo property=pageTopicMap title=%=((PageForm)pageInfo).getName()% c:out value=${pageInfo.pageSequence + 1}/ /html:link /c:forEach However, I get the following error when I try this: [ServletException in:/viewer/coursePage.jsp] Unable to compile class for JSP An error occured between lines: 83 and 84 in the jsp file: /viewer/coursePage.jsp Generated servlet error: D:\Tools\tomcat-4.0.1\work\localhost\onpoint\viewer\coursePage$jsp.java: 743: Undefined variable: pageInfo _jspx_th_html_link_0.setTitle(((PageForm)pageInfo).getName()); ^ 1 error ' -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: c:forEach compared to logic:iterate
On Tue, 23 Apr 2002, Matt Raible wrote: Which works great! However, I was hoping to migrate my logic tags to JSTL and the following doesn't work: c:forEach var=pageInfo items=${topicForm.pages} html:link forward=getPage name=pageInfo property=pageTopicMap title=%=((PageForm)pageInfo).getName()% JSTL's c:forEach tag doesn't expose a scripting variable, just a scoped attribute (which we call a scoped variable). You need to use jsp:useBean (or some other declaration mechanism) if you absolutely need scripting variables. Though I can't speak for Struts, my sense is that it is planning to accommodate JSTL's expression language (at the very least under JSP 1.3, where it will be the container's responsibility), which will minimize the need for scripting variables. Hope that helps, -- Shawn Bayern JSP Standard Tag Library http://www.jstlbook.com (coming this summer from Manning Publications) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: taglibs scope
On Wed, 24 Apr 2002, Cliffano Subagio wrote: I have a variable that would be used globally all over an application, c:set var=myGlobalVar scope=...Something/c:set and I put this code in 2 files a.jsp and b.jsp. What will happen if I use 'application' as the scope value? Once myGlobalVar is set in a.jsp, what will happen when the same exact code is encountered in b.jsp? Will it rewrite and overwrite the old myGlobalVar? or will it ignore the rewriting of the same myGlobalVar since myGlobalVar is already set with application scope? And will it behave differently if I set the scope as 'page' in the same scenario? There are two questions here, I believe. The first is, What happens if I try to overwrite an existing scoped variable (e.g., in application scope)? Here, the answer is simple: you can always overwrite a scoped variable. Using c:set will either create or replace a variable; nothing is sticky about the initial c:set. The second question, I believe, is, What happens if I have an application-scoped variable named 'foo' and try to set a page-scoped variable named 'foo'? The answer here, unfortunately, varies by implementation. The JSP standard technically provides for all scopes to represent a single namespace: if there is a 'foo' object, it has a single scope, and you can't have both ${pageScope.foo} and ${sessionScope.foo} at the same time. However, because the specification doesn't mandate that containers enforce this behavior, many don't, and (I would guess) most JSP users expect each scope to have its own namespace. The general advice that comes from all this is thus twofold: - There's absolutely no problem overwriting scoped variables within the same scope. - Avoid, when possible, using the same name in two different scopes to ensure your pages are portable from one container to another. JSTL's tags, like c:set, are neutral on the issue. They don't enforce more than their containers enforce. So they will let you create a page-scoped 'foo' if you have an application-scoped 'foo' as long as your container allows it; use this feature at your own risk. -- Shawn Bayern JSP Standard Tag Library http://www.jstlbook.com (coming this summer from Manning Publications) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]