sql:query - Aliases and Aggregates
Hi All, I have two questions about the use of sql:query: 1) Can sql:query handle aliases of the form select column1 as alias1 from table1. I find nothing in variable.alias1. If not, how does sql:query handle column name collisions (that are usually handled with an alias), 2) Can sql:query handle aggregates of the form select column1, count(*) from table1 group by column1. With reference to 1) above, does count(*) need to be aliased? I have tried and can't access it. Thanks, Brett Randall _ What's your house worth? Click here to find out: http://www.ninemsn.realestate.com.au - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Replacing returns with br
When I try putting the '\\\n' in with the escapeXmL attribute set to false, I get this: org.apache.jasper.JasperException: /filename.jsp(301,2) Attribute escapeXmL invalid for tag out according to TLD Which makes no sense what-so-ever. I tried just putting the escapeXmL=false attribute in with '\n' being my string, and I get my original error. I think the problem may be that it's not seeing \n as the return character from my database. Any ideas? Keith -- Original Message --- From: Pierre Delisle [EMAIL PROTECTED] To: Tag Libraries Users List [EMAIL PROTECTED] Sent: Tue, 13 Apr 2004 18:08:51 -0700 Subject: Re: Replacing returns with br Not very intuitive, but the following should work: c:set var=s5 value=First line\nSecond line/ c:out value=${fn:replace(s5,'\\\n','br')} escapeXml=false/ -- Pierre Keith wrote: I have a column in a database that is used to store a comments section. It's just a large string (VARCHAR2(4000) in Oracle), and the information is entered into it via a textarea form field. If I output that data to another textarea I can see that the return characters are preserved in the database. I was trying to output this column's data as normal text in HTML, but need to preserve the returns somehow. I was thinking I could use the fn:replace action to turn them into br's, but I'm not sure how it sees the return characters in the string. I tried this: c:out value=${fn:replace(row.comments, '\n', 'br')} / But get this error back: org.apache.jasper.JasperException: /filename.jsp(281,2) ${fn:replace (row.comments, '\n', 'br')} contains invalid expression(s): javax.servlet.jsp.el.ELException: Encountered '\n, expected one of [INTEGER_LITERAL, FLOATING_POINT_LITERAL, STRING_LITERAL, true, false, null, (, - , not, !, empty, IDENTIFIER] Anyone help with how I can go about doing this? Thanks! Keith - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- End of Original Message --- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Replacing returns with br
you have a typo: the attribute is escapeXml ,not escapeXmL (look at the 'L') -Original Message- From: Keith [mailto:[EMAIL PROTECTED] Sent: 14 April 2004 15:24 To: Tag Libraries Users List Subject: Re: Replacing returns with br When I try putting the '\\\n' in with the escapeXmL attribute set to false, I get this: org.apache.jasper.JasperException: /filename.jsp(301,2) Attribute escapeXmL invalid for tag out according to TLD Which makes no sense what-so-ever. I tried just putting the escapeXmL=false attribute in with '\n' being my string, and I get my original error. I think the problem may be that it's not seeing \n as the return character from my database. Any ideas? Keith -- Original Message --- From: Pierre Delisle [EMAIL PROTECTED] To: Tag Libraries Users List [EMAIL PROTECTED] Sent: Tue, 13 Apr 2004 18:08:51 -0700 Subject: Re: Replacing returns with br Not very intuitive, but the following should work: c:set var=s5 value=First line\nSecond line/ c:out value=${fn:replace(s5,'\\\n','br')} escapeXml=false/ -- Pierre Keith wrote: I have a column in a database that is used to store a comments section. It's just a large string (VARCHAR2(4000) in Oracle), and the information is entered into it via a textarea form field. If I output that data to another textarea I can see that the return characters are preserved in the database. I was trying to output this column's data as normal text in HTML, but need to preserve the returns somehow. I was thinking I could use the fn:replace action to turn them into br's, but I'm not sure how it sees the return characters in the string. I tried this: c:out value=${fn:replace(row.comments, '\n', 'br')} / But get this error back: org.apache.jasper.JasperException: /filename.jsp(281,2) ${fn:replace (row.comments, '\n', 'br')} contains invalid expression(s): javax.servlet.jsp.el.ELException: Encountered '\n, expected one of [INTEGER_LITERAL, FLOATING_POINT_LITERAL, STRING_LITERAL, true, false, null, (, - , not, !, empty, IDENTIFIER] Anyone help with how I can go about doing this? Thanks! Keith - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- End of Original Message --- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Replacing returns with br
Woops! :p Well, that got rid of the invalid attribute error. But, it's not doing the replacing. It looks like it would if I just did a normal c:out. I just went with a pre tag using a CSS style to change its appearance. Thanks for the help, though! -- Original Message --- From: Felix Velasco [EMAIL PROTECTED] To: 'Tag Libraries Users List' [EMAIL PROTECTED] Sent: Wed, 14 Apr 2004 15:22:53 +0200 Subject: RE: Replacing returns with br you have a typo: the attribute is escapeXml ,not escapeXmL (look at the 'L') -Original Message- From: Keith [mailto:[EMAIL PROTECTED] Sent: 14 April 2004 15:24 To: Tag Libraries Users List Subject: Re: Replacing returns with br When I try putting the '\\\n' in with the escapeXmL attribute set to false, I get this: org.apache.jasper.JasperException: /filename.jsp(301,2) Attribute escapeXmL invalid for tag out according to TLD Which makes no sense what-so-ever. I tried just putting the escapeXmL=false attribute in with '\n' being my string, and I get my original error. I think the problem may be that it's not seeing \n as the return character from my database. Any ideas? Keith -- Original Message --- From: Pierre Delisle [EMAIL PROTECTED] To: Tag Libraries Users List [EMAIL PROTECTED] Sent: Tue, 13 Apr 2004 18:08:51 -0700 Subject: Re: Replacing returns with br Not very intuitive, but the following should work: c:set var=s5 value=First line\nSecond line/ c:out value=${fn:replace(s5,'\\\n','br')} escapeXml=false/ -- Pierre Keith wrote: I have a column in a database that is used to store a comments section. It's just a large string (VARCHAR2(4000) in Oracle), and the information is entered into it via a textarea form field. If I output that data to another textarea I can see that the return characters are preserved in the database. I was trying to output this column's data as normal text in HTML, but need to preserve the returns somehow. I was thinking I could use the fn:replace action to turn them into br's, but I'm not sure how it sees the return characters in the string. I tried this: c:out value=${fn:replace(row.comments, '\n', 'br')} / But get this error back: org.apache.jasper.JasperException: /filename.jsp(281,2) ${fn:replace (row.comments, '\n', 'br')} contains invalid expression(s): javax.servlet.jsp.el.ELException: Encountered '\n, expected one of [INTEGER_LITERAL, FLOATING_POINT_LITERAL, STRING_LITERAL, true, false, null, (, - , not, !, empty, IDENTIFIER] Anyone help with how I can go about doing this? Thanks! Keith - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- End of Original Message --- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- End of Original Message --- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: c:out
Andy, You might want to check to see if your web.xml file is setup correctly. Here is a link to the differences: http://www.haidleconsulting.com/articles/jspdiffs/ You should make sure that your web.xml has the header for JSP 2.0 (JSTL 1.1). Derek --- Andrew Nelson [EMAIL PROTECTED] wrote: Hello all - I have this bit of code in a jsp page. %@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core; % c:set var=blah scope=application blah /c:set c:out value=${blah} default=blah was emtpy/ Here is the output I get on the html page. ${blah}. I looked at the actual html generated and that is all there is. I thought maybe there would be a c:out or something but there isn't. No errors, no nothing. So I thought maybe there was something wrong with my container installation. I then installed the example apps and installed them and they worked perfectly. So now I'm stumped. If anyone has any idea I would love to hear it. I have tried java 1.4 and java 1.3(with the extra libraries in my WEB-INF/lib) but still I have had no luck. Thanks for any and all help. //Andy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = __ Do you Yahoo!? Yahoo! Tax Center - File online by April 15th http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: out
Have you tried just installing other jsp pages into your app's directory (not auto-installing the example war file)? The reason I ask is that your example works fine in the directory of a currently installed app of mine. So it seems that it does have something to do with your app installation (war). -Original Message- From: Andrew Nelson [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 14, 2004 10:42 AM To: [EMAIL PROTECTED] Subject: c:out Hello all - I have this bit of code in a jsp page. %@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core; % c:set var=blah scope=application blah /c:set c:out value=${blah} default=blah was emtpy/ Here is the output I get on the html page. ${blah}. I looked at the actual html generated and that is all there is. I thought maybe there would be a c:out or something but there isn't. No errors, no nothing. So I thought maybe there was something wrong with my container installation. I then installed the example apps and installed them and they worked perfectly. So now I'm stumped. If anyone has any idea I would love to hear it. I have tried java 1.4 and java 1.3(with the extra libraries in my WEB-INF/lib) but still I have had no luck. Thanks for any and all help. //Andy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
error when i try to use jstl xml tags in a page that doesn't participate in the session
Hi, If i have a page that does not participate in the session ( via %@ page session=false % ) Whenever I try to access some variable ( via either x:set/x:out/x:forEach ) i get the following error ( listed at end ) Is this a known issue? Shouldn't the XPathUtil ignore the session scope when it should not be accessing it? thanks, -a java.lang.IllegalStateException: Cannot access session scope in page that does not participate in any session at org.apache.jasper.runtime.PageContextImpl.doGetAttributeNamesInScope(PageContextImpl.java:546) at org.apache.jasper.runtime.PageContextImpl.getAttributeNamesInScope(PageContextImpl.java:532) at org.apache.taglibs.standard.tag.common.xml.XPathUtil.getVariableQNames(Unknown Source) at org.apache.taglibs.standard.tag.common.xml.XPathUtil.fillVarStack(Unknown Source) at org.apache.taglibs.standard.tag.common.xml.XPathUtil.selectNodes(Unknown Source) at org.apache.taglibs.standard.tag.common.xml.SetTag.doStartTag(Unknown Source) at org.apache.jsp.templates.yesterday_005fanswer_005fcallout_jsp._jspx_meth_x_set_0(yesterday_005fanswer_005fcallout_jsp.java:253) at org.apache.jsp.templates.yesterday_005fanswer_005fcallout_jsp._jspService(yesterday_005fanswer_005fcallout_jsp.java:124) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:589) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499) at org.apache.taglibs.standard.tag.common.core.ImportSupport.acquireString(Unknown Source) at org.apache.taglibs.standard.tag.common.core.ImportSupport.doEndTag(Unknown Source) at org.apache.jsp.promotions.moms_005fservice_005fthanks_jsp._jspx_meth_c_import_1(moms_005fservice_005fthanks_jsp.java:239) at org.apache.jsp.promotions.moms_005fservice_005fthanks_jsp._jspx_meth_cms_bodyModule_0(moms_005fservice_005fthanks_jsp.java:184) at org.apache.jsp.promotions.moms_005fservice_005fthanks_jsp._jspx_meth_c_param_0(moms_005fservice_005fthanks_jsp.java:142) at org.apache.jsp.promotions.moms_005fservice_005fthanks_jsp._jspx_meth_c_import_0(moms_005fservice_005fthanks_jsp.java:100) at org.apache.jsp.promotions.moms_005fservice_005fthanks_jsp._jspService(moms_005fservice_005fthanks_jsp.java:64) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:589) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499) at clubmom.framework.DisplayServlet.service(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312) at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:712) at
Re: c:out
Fixing my web.xml fixed the problem. Thankyou so very much for your help. I had been working on that for 3 days if you can believe it. You fixed it for me in a matter of minutes. Thanks again //Andy [EMAIL PROTECTED] 04/14/04 10:16AM Andy, You might want to check to see if your web.xml file is setup correctly. Here is a link to the differences: http://www.haidleconsulting.com/articles/jspdiffs/ You should make sure that your web.xml has the header for JSP 2.0 (JSTL 1.1). Derek --- Andrew Nelson [EMAIL PROTECTED] wrote: Hello all - I have this bit of code in a jsp page. %@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core; % c:set var=blah scope=application blah /c:set c:out value=${blah} default=blah was emtpy/ Here is the output I get on the html page. ${blah}. I looked at the actual html generated and that is all there is. I thought maybe there would be a c:out or something but there isn't. No errors, no nothing. So I thought maybe there was something wrong with my container installation. I then installed the example apps and installed them and they worked perfectly. So now I'm stumped. If anyone has any idea I would love to hear it. I have tried java 1.4 and java 1.3(with the extra libraries in my WEB-INF/lib) but still I have had no luck. Thanks for any and all help. //Andy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = __ Do you Yahoo!? Yahoo! Tax Center - File online by April 15th http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
While Conditional action?
Might be having a dense moment here, so excuse me if I'm missing something obvious... Is there any kind of while conditional loop functionality in the JSTL? As far as I can see, c:forEach only loops for a fixed number of times, or once for each item in a collection of some sort. Is there some way to use the c:choose action to loop on a condition? Or is this not in JSTL yet? Seems like a major oversite if it's missing. Keith - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Unable to initialize TldLocationsCache: no !/ in spec
Ok, I can't find the answer to this problem in this archive, the tag lib developers archive, the tomcat archive, or the Sun java web site -- oh, and also Google of course. Here's the situation, I've got a single page with a single line of code: %@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core; % That's it. Here's my web.xml: ?xml version=1.0 encoding=ISO-8859-1? web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; version=2.4 display-nameFoo/display-name /web-app I'm getting this error when calling the page: org.apache.jasper.JasperException: Unable to initialize TldLocationsCache: no !/ in spec org.apache.jasper.compiler.TldLocationsCache.init(TldLocationsCache.java:210) org.apache.jasper.compiler.TldLocationsCache.getLocation(TldLocationsCache.java:181) org.apache.jasper.JspCompilationContext.getTldLocation(JspCompilationContext.java:516) org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:457) org.apache.jasper.compiler.Parser.parseDirective(Parser.java:523) org.apache.jasper.compiler.Parser.parseElements(Parser.java:1577) org.apache.jasper.compiler.Parser.parse(Parser.java:171) org.apache.jasper.compiler.ParserController.parse(ParserController.java:253) org.apache.jasper.compiler.ParserController.parse(ParserController.java:137) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:237) org.apache.jasper.compiler.Compiler.compile(Compiler.java:456) org.apache.jasper.compiler.Compiler.compile(Compiler.java:439) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) Help! I'm not sure what it going on. I've simplified all of the files down to the above and I can't figure out the error -- I'm probably missing something simple. Thanks in advance for your time! Oh, I can use EL on a web page -- just not a call to the core tag library. By the way, the exact same setup on a different virtual host (same computer, same jvm, same Tomcat instance) works just fine. Any ideas? Derek = __ Do you Yahoo!? Yahoo! Tax Center - File online by April 15th http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: sql:query - Aliases and Aggregates
Brett Randall wrote: I have two questions about the use of sql:query: 1) Can sql:query handle aliases of the form select column1 as alias1 from table1. 2) Can sql:query handle aggregates of the form select column1, count(*) from table1 group by column1. With reference to 1) above, does count(*) need to be aliased? Yes to all; here's an example I'm using right now -- works fine :-) sql:query var=quantities SELECT count(product) as thisQuantity FROM inventoryByProduct WHERE product = ? GROUP BY product sql:param value=${product}/ /sql:query c:set var=inventoryCount value=${quantities.rows[0].thisQuantity}/ HTH! -- Hassan Schroeder - [EMAIL PROTECTED] Webtuitive Design === (+1) 408-938-0567 === http://webtuitive.com dream. code. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]