Question regarding c:if
Hi, when using c:if with EL=ECMAscript, what are the semantics with the comparison operator ==, e.g. with test=$test == 'test', i.e. it seems that if the variable test is not a string, the test always fails (when I set the variable with c:set var=test value=$result.getRows()[0].get(0) scope=session on column generated with select 'test', the above test fails, when I use c:set var=test value=$result.getRows()[0].get(0).toString() scope=session it works. Thank you very much in advance, Wolfgang smime.p7s Description: S/MIME Cryptographic Signature
RE: Hello, and need help
The execute tag is meant for updates, inserts and deletes. What you probably want to use is the resultSet tag. sql:resultSet id=myRS % for( int i = 0; i val.size(); i++ )// What is val??? { % sql:getColumn position=%=i%/ % } % /sql:execute I think you're trying to print all the values that are returned from your query. I'm unsure of the origin of the variable 'val'. The resultSet tag will loop through all the rows by default, I assume the 'for loop' is meant to loop through all the fields in each given row in the result, thus val.size() should return the number of fields you're selecting in your where clause. -Original Message- From: Brady Moritz [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 2:15 AM To: 'Tag Libraries Users List' Subject: RE: Hello, and need help Sorry to repeat, but does anyone have a clue on this or should I go about this a different way? Brady Moritz -Original Message- From: Brady Moritz [mailto:[EMAIL PROTECTED]] Sent: Monday, January 28, 2002 6:01 AM To: 'Tag Libraries Users List' Subject: Hello, and need help Hi everyone, Im new to the list so good to meet you. Any pointers on why the following code is disallowed, and a quick way to code around it? Apparently prepared statements do not allow run-time resolution of the query string. sql:query select * from orders where %= where % //where contains the where clause, with columnname=? repeated. //this build a dynamic query with varying number of elements /sql:query sql:execute % for(int i = 0; i val.size(); i++){ % sql:setColumn position=% out.write(String.valueOf(i)); % %= val.elementAt(0) %/sql:setColumn % } % /sql:execute Brady Moritz -- 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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Accessing session scoped variables from exppression languageinthe standard taglib: Howto?
On Tue, 29 Jan 2002, Wolfgang Röckelein wrote: BTW: Where should we provide input to the EL discussion? Is this discussion public? It can be discussed informally here. More formally, the subject has now been taken up by the JSR-152 group, so I should defer to Eduardo Pelegri-Llopart and Mark Roth (the spec leads) in describing how they're prefer community feedback on the EL. My guess is that the [EMAIL PROTECTED] feedback alias would work. Does the ECMA implementation support all scopes that SPEL supports: page, request, session, app, header, param, paramvalues? No, I think the current ECMAScript implementatino supports only scoped attributes (page, request, session, and app). The final EL will most likely support more than this, though. Regarding the question regarding and, or, not on http://jakarta.apache.org/taglibs/doc/standard-doc/spel/spel.html: I think this depends on the goal of the JSTL in whole: Should there still be normal to use Java code in JSP or is the aim that most Java code should be replaced with tag lib usage? If the later is the goal, the EL needs not only boolean operators but eg math and string operators, too. Excellent point; I agree with this too. My sense is that there's consensus on this issue from others debating the topic, too. BTW: Are you sure that the core-rt version of if works? I never succeeded in getting the body evaluated, even with test=1==1... It works for me: crt:if test=%= 1==1 % 1 does indeed equal 1, interestingly enough /crt:if If you're still having trouble with it, let us know; please show the entire JSP page and include info about what container you're using. Best, -- Shawn Bayern Author, JSP Standard Tag Library (Manning, upcoming) http://jstlbook.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Hello, and need help
What im actually trying to accomplish is two things: - create a dynamic prepared statement each time so I can add where clauses to it. - use of the stmt instead of a normal query because I don't want to mess with figuring out if the where clause item needs to be quoted or not etc. val is a vector with all the values want to populate the preparedstament with... but apparently it doens tlike you to have variables ere and wants this data to b static. I didn't show the full tagset earlier, it is encompassed by a preapredstatement tag. sql:preparedStatement id=stmt1 conn=conn1 %-- set the SQL query. note the lack of quotes around the name value --% sql:query select * from orders where %= where % /sql:query sql:execute %for(int i = 0; i val.size(); i++){ % sql:setColumn position=%= i % %= val.elementAt(0) %/sql:setColumn %} % /sql:execute /sql:preparedStatement Brady Moritz -Original Message- From: Mader, Steve [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 7:39 AM To: 'Tag Libraries Users List' Subject: RE: Hello, and need help The execute tag is meant for updates, inserts and deletes. What you probably want to use is the resultSet tag. sql:resultSet id=myRS % for( int i = 0; i val.size(); i++ )// What is val??? { % sql:getColumn position=%=i%/ % } % /sql:execute I think you're trying to print all the values that are returned from your query. I'm unsure of the origin of the variable 'val'. The resultSet tag will loop through all the rows by default, I assume the 'for loop' is meant to loop through all the fields in each given row in the result, thus val.size() should return the number of fields you're selecting in your where clause. -Original Message- From: Brady Moritz [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 2:15 AM To: 'Tag Libraries Users List' Subject: RE: Hello, and need help Sorry to repeat, but does anyone have a clue on this or should I go about this a different way? Brady Moritz -Original Message- From: Brady Moritz [mailto:[EMAIL PROTECTED]] Sent: Monday, January 28, 2002 6:01 AM To: 'Tag Libraries Users List' Subject: Hello, and need help Hi everyone, Im new to the list so good to meet you. Any pointers on why the following code is disallowed, and a quick way to code around it? Apparently prepared statements do not allow run-time resolution of the query string. sql:query select * from orders where %= where % //where contains the where clause, with columnname=? repeated. //this build a dynamic query with varying number of elements /sql:query sql:execute % for(int i = 0; i val.size(); i++){ % sql:setColumn position=% out.write(String.valueOf(i)); % %= val.elementAt(0) %/sql:setColumn % } % /sql:execute Brady Moritz -- 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] -- 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: Hello, and need help
Change the section of dbtags.tld for the setColumn tag to have the value yes in the rtexprvalue tag, and restart your server. tag namesetColumn/name tagclassorg.apache.taglibs.dbtags.preparedstatement.SetColumnTag/tagclass bodycontentJSP/bodycontent attribute nameposition/name requiredyes/required rtexprvalueyes/rtexprvalue /attribute /tag rtexprvalueyes/rtexprvalue was rtexprvalueno/rtexprvalue I think this what you're looking for. Hope it helps. -Original Message- From: Brady Moritz [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 12:03 PM To: 'Tag Libraries Users List' Subject: RE: Hello, and need help What im actually trying to accomplish is two things: - create a dynamic prepared statement each time so I can add where clauses to it. - use of the stmt instead of a normal query because I don't want to mess with figuring out if the where clause item needs to be quoted or not etc. val is a vector with all the values want to populate the preparedstament with... but apparently it doens tlike you to have variables ere and wants this data to b static. I didn't show the full tagset earlier, it is encompassed by a preapredstatement tag. sql:preparedStatement id=stmt1 conn=conn1 %-- set the SQL query. note the lack of quotes around the name value --% sql:query select * from orders where %= where % /sql:query sql:execute %for(int i = 0; i val.size(); i++){ % sql:setColumn position=%= i % %= val.elementAt(0) %/sql:setColumn %} % /sql:execute /sql:preparedStatement Brady Moritz -Original Message- From: Mader, Steve [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 7:39 AM To: 'Tag Libraries Users List' Subject: RE: Hello, and need help The execute tag is meant for updates, inserts and deletes. What you probably want to use is the resultSet tag. sql:resultSet id=myRS % for( int i = 0; i val.size(); i++ )// What is val??? { % sql:getColumn position=%=i%/ % } % /sql:execute I think you're trying to print all the values that are returned from your query. I'm unsure of the origin of the variable 'val'. The resultSet tag will loop through all the rows by default, I assume the 'for loop' is meant to loop through all the fields in each given row in the result, thus val.size() should return the number of fields you're selecting in your where clause. -Original Message- From: Brady Moritz [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 2:15 AM To: 'Tag Libraries Users List' Subject: RE: Hello, and need help Sorry to repeat, but does anyone have a clue on this or should I go about this a different way? Brady Moritz -Original Message- From: Brady Moritz [mailto:[EMAIL PROTECTED]] Sent: Monday, January 28, 2002 6:01 AM To: 'Tag Libraries Users List' Subject: Hello, and need help Hi everyone, Im new to the list so good to meet you. Any pointers on why the following code is disallowed, and a quick way to code around it? Apparently prepared statements do not allow run-time resolution of the query string. sql:query select * from orders where %= where % //where contains the where clause, with columnname=? repeated. //this build a dynamic query with varying number of elements /sql:query sql:execute % for(int i = 0; i val.size(); i++){ % sql:setColumn position=% out.write(String.valueOf(i)); % %= val.elementAt(0) %/sql:setColumn % } % /sql:execute Brady Moritz -- 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] -- 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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Accessing session scoped variables from exppression languageinthe standard taglib: Howto?
Hi, Shawn Bayern wrote: BTW: Are you sure that the core-rt version of if works? I never succeeded in getting the body evaluated, even with test=1==1... It works for me: crt:if test=%= 1==1 % 1 does indeed equal 1, interestingly enough /crt:if Aha, this is how it is supposed to work. I tried crt:if test=1==1 i.e. I assumed that the tag includes the %= construct. Thank you very much, Wolfgang smime.p7s Description: S/MIME Cryptographic Signature
NullPointerException Error
Hi, I'm a JSP newbie and am having trouble using the DBTags library. I have a simple page which is intended to open an MS Access database and display three columns of information from one table. I'm getting a NullPointerException when the page compiles: java.lang.NullPointerException at org.apache.taglibs.dbtags.connection.ConnectionTag.doEndTag(ConnectionTag.ja va:221) at org.apache.jsp.Phone1$jsp._jspService(Phone1$jsp.java:86) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja va:202) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja va:243) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja va:201) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164 ) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve. java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170 ) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java :163) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java: 1011) at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106 ) at java.lang.Thread.run(Thread.java:484) The page code is as follows: ++ %@ taglib uri=http://jakarta.apache.org/taglibs/dbtags; prefix=sql % html head meta http-equiv=Content-Language content=en-us meta http-equiv=Content-Type content=text/html; charset=windows-1252 meta name=GENERATOR content=Microsoft FrontPage 4.0 meta name=ProgId content=FrontPage.Editor.Document style a{font-family:verdana; font-size:8pt; color:blue; text-decoration:none; font-weight:bold;} a:hover{color:red; text-decoration:underline;} td{font-family:verdana; font-size:8pt; font-weight:bold;} /style titleUser Activity/title /head body !-- Open database connection -- sql:connection id=conn1 dataSource=PhoneList /sql:connection !-- This is the database query -- sql:statement id=stmt1 conn=conn1 sql:query SELECT * FROM LIST ORDER BY Name /sql:query h1 align=centerbPDBI Phone List/b/h1 div align=center center table border=0 width=75% tr td width=30% style=background-color:#6699CC;Name/td td width=30% style=background-color:#6699CC;Room/td td width=20% style=background-color:#6699CC;Phone/td /tr !-- Loop through the rows of the query and display in the table -- sql:resultSet id=rs tr td align=leftsql:getColumn position=2//td td align=leftsql:getColumn position=3//td td align=leftsql:getColumn position=4/ sql:wasNullNo records returned/sql:wasNull/td /tr /sql:resultSet /sql:statement
Newlines in attributes
In my example for the string-taglib, I stupidly gave an example of: str:replace replace=\n with=br\ndb:get value=data/str:replace without testing. Where db:get is a hypothetical tag creating data. The example doesn't work because the \n in the tag gets turned into a normal 'n' before it hits the Tag object. Is there a way to solve this that I am missing? Sending: \\n just sends through what you'd expect, \ and n. And sending: #92n does just the same. I assume that a \t and \b etc won't work either. So my current solution is an attribute to my tag which says to treat any \n's as being real newlines and not the characters \ and n. Seems a bit painful though. Or a new tag. Bay -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Hello, and need help
Very cool, ill give it a try. Thanks! Brady Moritz -Original Message- From: Mader, Steve [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 11:30 AM To: 'Tag Libraries Users List' Subject: RE: Hello, and need help Change the section of dbtags.tld for the setColumn tag to have the value yes in the rtexprvalue tag, and restart your server. tag namesetColumn/name tagclassorg.apache.taglibs.dbtags.preparedstatement.SetColumnTag/tagc lass bodycontentJSP/bodycontent attribute nameposition/name requiredyes/required rtexprvalueyes/rtexprvalue /attribute /tag rtexprvalueyes/rtexprvalue was rtexprvalueno/rtexprvalue I think this what you're looking for. Hope it helps. -Original Message- From: Brady Moritz [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 12:03 PM To: 'Tag Libraries Users List' Subject: RE: Hello, and need help What im actually trying to accomplish is two things: - create a dynamic prepared statement each time so I can add where clauses to it. - use of the stmt instead of a normal query because I don't want to mess with figuring out if the where clause item needs to be quoted or not etc. val is a vector with all the values want to populate the preparedstament with... but apparently it doens tlike you to have variables ere and wants this data to b static. I didn't show the full tagset earlier, it is encompassed by a preapredstatement tag. sql:preparedStatement id=stmt1 conn=conn1 %-- set the SQL query. note the lack of quotes around the name value --% sql:query select * from orders where %= where % /sql:query sql:execute %for(int i = 0; i val.size(); i++){ % sql:setColumn position=%= i % %= val.elementAt(0) %/sql:setColumn %} % /sql:execute /sql:preparedStatement Brady Moritz -Original Message- From: Mader, Steve [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 7:39 AM To: 'Tag Libraries Users List' Subject: RE: Hello, and need help The execute tag is meant for updates, inserts and deletes. What you probably want to use is the resultSet tag. sql:resultSet id=myRS % for( int i = 0; i val.size(); i++ )// What is val??? { % sql:getColumn position=%=i%/ % } % /sql:execute I think you're trying to print all the values that are returned from your query. I'm unsure of the origin of the variable 'val'. The resultSet tag will loop through all the rows by default, I assume the 'for loop' is meant to loop through all the fields in each given row in the result, thus val.size() should return the number of fields you're selecting in your where clause. -Original Message- From: Brady Moritz [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 2:15 AM To: 'Tag Libraries Users List' Subject: RE: Hello, and need help Sorry to repeat, but does anyone have a clue on this or should I go about this a different way? Brady Moritz -Original Message- From: Brady Moritz [mailto:[EMAIL PROTECTED]] Sent: Monday, January 28, 2002 6:01 AM To: 'Tag Libraries Users List' Subject: Hello, and need help Hi everyone, Im new to the list so good to meet you. Any pointers on why the following code is disallowed, and a quick way to code around it? Apparently prepared statements do not allow run-time resolution of the query string. sql:query select * from orders where %= where % //where contains the where clause, with columnname=? repeated. //this build a dynamic query with varying number of elements /sql:query sql:execute % for(int i = 0; i val.size(); i++){ % sql:setColumn position=% out.write(String.valueOf(i)); % %= val.elementAt(0) %/sql:setColumn % } % /sql:execute Brady Moritz -- 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] -- 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] -- 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]