Grtting an Error while using forEach tag
Dear All, I am using forEach tag for iterating over an ArrayList present in the session scope. The code I have used is core:forEach var=image items=${TREE-IMAGES} -- -- /core:forEach When i execute this page I get the following error An error occurred while evaluating custom action attribute items with value ${TREE-IMAGES}: Attempt to coerce a value of type java.util.ArrayList to type java.lang.Long (null But if I get the value and store it in a different name the forEach tag works properly. The changed code is % java.util.ArrayList list = (java.util.ArrayList)pageContext.findAttribute(TREE-IMAGES); session.setAttribute(IMAGES,list); % core:forEach var=image items=IMAGES - - /core:forEach This works properly. Will there be a problem if there is a - in the variabe name or have i misunderstood something. Thanks Shanmugam PL - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[Fwd: Having an expression in an set tag]
---BeginMessage--- Hi All, I used to construct a link as follows % String link = request.getRequestURL() + "?nodeclicked=" + NODEID + "firstChild=true"; % I want to replace this with the set tag. I tried it as follows c:set var="link" value="${request.requestURL + '?nodeClicked=' + NODEID + 'firstChild=true'}"/ but this is not working. I am getting the following an error An exception occured trying to convert String "?nodeClicked" to type "java.lang.Double" Have i done anything wrong in writing the _expression_. Thanks Shanmugam PL ---End Message--- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Whitespace Galore!
-- Forwarded message -- Date: Fri, 4 Jul 2003 19:15:06 -0230 (NDT) From: Neil Zanella [EMAIL PROTECTED] To: Tag Libraries Users List [EMAIL PROTECTED] Subject: Re: Whitespace Galore! On Mon, 30 Jun 2003, Rick Ross wrote: 2. There is a ton of whitespace all over my output. Many many newlines ... so many, that it is hard to examine the source of the output. I think that most of it is in the bodies of conditionals... anyone else having problems? Yes!!! This is the one feature I miss the very most about PHP tags, which, are such that an entire line enclosed within ?php /* ... */ ? will be stripped off together with the newline character that follows it for pretty output! I really cannot understand why JSP doesn't do this and hope that this will change in the future: Q: How can you tell a page is written with JSP? A: If when you view page source in your web browser you see that there are a lot of runs of consecutive blank lines! It looks sloppy!!! ... and is unfriendly and makes the output hard to debug and read! There must be a way around it; there must, otherwise JSP sucks. So how can it be achieved? Regards, Neil - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
SQL tag library installation question
Hello, I wonder whether anyone has been using the SQL tag library. I am wondering about the following: As it seems to me that Tomcat does not make use of the CLASSPATH variable at all (i.e. it does not read it when it is started) (is this correct?), then how can Tomcat possibly find on the system some JDBC driver such as org.postgresql.Driver installed on the system as a JAR file whose absolute path name is given by: /usr/lib/pgsql/jdbc7.0-1.2.jar I cannot make out how Tomcat would know to look in such a place in the first place. Anyone know how it is done? Also, is anyone using tomcat with Red Hat 9 and postgresql? I cannot seem to be able to start the postmaster with the -i flag (used to enable network connections, necessary for JDBC connections too apparently). Thanks, Neil - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: SQL tag library installation question
Hi Neil, We put the JDBC jar file in $CATALINA_HOME/shared/lib. There our webapps can share it. Peter -- Peter Smith Software Engineer InfoNow Corporation From: Neil Zanella [EMAIL PROTECTED] Reply-To: Tag Libraries Users List [EMAIL PROTECTED] Date: Sat, 5 Jul 2003 18:15:07 -0230 (NDT) To: Taglibs User Mailing List [EMAIL PROTECTED] Subject: SQL tag library installation question Hello, I wonder whether anyone has been using the SQL tag library. I am wondering about the following: As it seems to me that Tomcat does not make use of the CLASSPATH variable at all (i.e. it does not read it when it is started) (is this correct?), then how can Tomcat possibly find on the system some JDBC driver such as org.postgresql.Driver installed on the system as a JAR file whose absolute path name is given by: /usr/lib/pgsql/jdbc7.0-1.2.jar I cannot make out how Tomcat would know to look in such a place in the first place. Anyone know how it is done? Also, is anyone using tomcat with Red Hat 9 and postgresql? I cannot seem to be able to start the postmaster with the -i flag (used to enable network connections, necessary for JDBC connections too apparently). Thanks, Neil - 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: Problems with c:out tag
I've run into the same issue but with a different tag other than c:out. I'm assuming they are related but I'm really looking for some advice here... I'm in the process of converting my application to JSTL from Struts tags. Once Struts 1.1 Release Candidate 2 came out supporting EL I decided to stick with Struts EL since converting the entire application to JSTL and removing all of my Struts tags didn't seem possible when I started to run into this issue. In my original code I had the following if statement within my JSP... logic:equal name=adminDownloadForm property=idFlag value=true %-- Show some related information if 'idFlag' evaluates to true --% /logic:equal The above worked just fine and returned the expected information. When I tried to convert this simple if statement to JSTL I ran into a problem... Here's the code I attempted to use... c:if test=${adminDownloadForm.idFlag} %-- Show some related information if 'idFlag' evaluates to true --% /c:if Once I tried the c:if tag and executed the JSP I received the error described by Matt below... An error occurred while evaluating custom action attribute value with value ${adminDownloadForm.idFlag}: Unable to find a value for ifFlag in object of class com..xxx..xxx using operator . (null)' JSTL is not aware of the adminDownloadForm object. I know this Form is related to Struts but the behavior of these JSTL tags is inconsistent. In order to get my c:if tag to work properly I had to use a bean:define tag from the Struts library and define the 'idFlag' variable. Now if I do something like this, my c:if tag works fine bean:define id=idFlag name=adminDownloadForm property=idFlag / c:if test=${idFlag} /c:if But now I'm writing two lines of code when all I needed was one line using the logic:equals tag from the Struts library. I know an additional line of code is not the end of the world but which is better practice? Is having Struts tags and JSTL tags in your JSP bad practice? Could it cause confusion to other developers down the road? Back to my point of JSTL being inconsistent... I have this standalone tag in my JSP (with no bean define or c:set and I do not get an exception from this tag... It works just fine c:forEach var=assetType items=${summaryForm.assetTypeQueues} What's confusing and inconsistent is that I didn't need to define the 'summaryForm' object. It was capable of seeing it and extracted the variable I asked from it just fine. Why doesn't the c:if tag act in the same manner? Is this a bug or am I doing something wrong? I apologize for the novel I just wrote but I didn¹t want to leave out any details. Any advice would be greatly appreciated. Thanks - Billy - On 7/3/03 9:47 AM, Michael Duffy [EMAIL PROTECTED] wrote: Hi Sgarlata, I had this problem, too. Drove me crazy! I had a class named Component that didn't behave correctly. When I renamed the class to AssemblyComponent, everything worked fine. The only class in the JDK that might interfere this way is java.awt.Component. I'm not sure how it happens, but JSTL couldn't find my methods on my Component class. I know it's not a great answer, but it is a workaround. At least I can offer my sympathy - I suffered with this, too. - MOD --- Sgarlata Matt [EMAIL PROTECTED] wrote: Hello, I'm having some problems with the c:out tag (and also with the bean:write tag from Struts) where I have some code that works in one application but does not work in another application. I know my variables are set out correctly because of some scriptlet code. Here is the working code: c:forEach items=${lookup.days} var=day c:out value=${day.title}/ /c:forEach Here is the same code that does not work in another application: c:forEach items=${lookup.components} var=component c:out value=${component.shortDesc}/ /c:forEach The error message is: An error occurred while evaluating custom action attribute value with value ${component.shortDesc}: Unable to find a value for shortDesc in object of class com.bah.ebspnp.dao.Component using operator . (null)' However, this does work correctly: c:forEach items=${lookup.components} var=item %= ((Component)pageContext.getAttribute(item)).getShortDesc() % /c:forEach Any ideas? Thanks! Matt __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com - 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: Jakarta Taglibs Installation
do you have taglib define in the web.xml file? might be the ordering of your other directives, try looking at the DTD. nick On Fri, 4 Jul 2003, Neil Zanella wrote: Well, now I am not entirely sure that it is mandatory, because I have a JSP page such that when I change the WEB-INF/web.xml to include the following lines (for connecting to a database which is not yet on the network): context-param param-name javax.servlet.jsp.jstl.sql.dataSource /param-name param-value jdbc:postgresql:foodb,org.postgresql.Driver,johndoe /param-value /context-param and save the .jsp file without making any modifications to it, I get the following error, but the error is not caused by a change in the .jsp file; it's caused by the above lines: org.apache.jasper.JasperException: This absolute uri (http://java.sun.com/jstl/core) cannot be resolved in either web.xml or the jar files deployed with this application This is clearly wrong!!! BTW I have not been able to connect to the data source yet so I'm not sure yet if that would fix it, but the error is clearly the wrong error, and is introduced by the above lines. Why is this happening? (almost would seem like a bug: Tomcat 4.1.24) Neil On Mon, 30 Jun 2003, Shawn Bayern wrote: On Mon, 30 Jun 2003, [gb2312] guo yingshou wrote: If it is *mandatory*,why the web-app.dtd still specifiy an optional taglib element?Just for backward compatibility? That's part of it, and it's also necessary for cases where a tag library doesn't package its JAR in the format necessary for it to work. Note that it's mandatory for the container to support it; it's not mandatory for a taglib author to deploy his or her libraries in this fashion (though it's probably a good idea in all cases). - 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]
JSTL Tag in a directive.
I can't seem to get this to work: %@ includes file=c:out value='${includePage}' / % I didn't see anything in the Spec that suggests that it would violate spec, but it wasn't mentioned either (as far as I saw.) Since I need the contents of includePage to be processed as JSP, I think I am SOL and will have to wrap it in a choose/when tag c:choose c:when test=${includePage == 'somepage.jsp' %@ includes file=somepage.jsp % /c:when /c:choose Am I missing something? The reference is always local, but when I tried c:import It wouldn't process the JSTL tags in somepage.jsp. I appreciate any feedback Rick
Re: Problems with c:out tag
Thanks for your response Hans, that was very helpful. This might be more of a Struts issue then because I don't have a JavaBean for my 'Form' object. I use the Struts DynaActionForm object which does all the 'getting' and 'setting' for you. I have this element defined in my struts-config.xml file... form-bean name=adminDownloadForm type=org.apache.struts.action.DynaActionForm form-property name=idFlag type=java.lang.Boolean / /form-bean Defining the property 'idFlag' with a type Boolean is all I have to do and Struts pretty much does the rest of the getting/setting. I'm not sure how the DynaActionForm is implemented since it's a core Struts class but in anycase it doesn't look like I could fix this since I don't define the Bean. Thanks for the input! - Billy - On 7/5/03 6:53 PM, Hans Bergsten [EMAIL PROTECTED] wrote: Billy Bacon wrote: I've run into the same issue but with a different tag other than c:out. I'm assuming they are related but I'm really looking for some advice here... I'm in the process of converting my application to JSTL from Struts tags. Once Struts 1.1 Release Candidate 2 came out supporting EL I decided to stick with Struts EL since converting the entire application to JSTL and removing all of my Struts tags didn't seem possible when I started to run into this issue. In my original code I had the following if statement within my JSP... logic:equal name=adminDownloadForm property=idFlag value=true %-- Show some related information if 'idFlag' evaluates to true --% /logic:equal The above worked just fine and returned the expected information. When I tried to convert this simple if statement to JSTL I ran into a problem... Here's the code I attempted to use... c:if test=${adminDownloadForm.idFlag} %-- Show some related information if 'idFlag' evaluates to true --% /c:if Once I tried the c:if tag and executed the JSP I received the error described by Matt below... An error occurred while evaluating custom action attribute value with value ${adminDownloadForm.idFlag}: Unable to find a value for ifFlag in object of class com..xxx..xxx using operator . (null)' This means that there's something quite not right with the idFlag property in your bean. The JSTL EL goes strictly by the JavaBeans specification, so the bean must satisfy all rules for the property access methods. A quite common problem is to have a getter method that returns an object of one type, and a setter method that takes an object of another type: public class MyBean { ... public boolean getIdFlag() {...} public setIdFlag(String value) {...} } This is not valid according to the JavaBeans spec, so the end result is that this class doesn't define a property named idFlag at all, even though it has a getIdFlag() method. JSTL is not aware of the adminDownloadForm object. I know this Form is related to Struts but the behavior of these JSTL tags is inconsistent. In order to get my c:if tag to work properly I had to use a bean:define tag from the Struts library and define the 'idFlag' variable. Now if I do something like this, my c:if tag works fine bean:define id=idFlag name=adminDownloadForm property=idFlag / c:if test=${idFlag} /c:if I have not looked at the Struts code, but I assume that it doesn't use the JavaBeans support classes to get the property value. If it uses plain introspection to get hold of a method called getIdFlag() and call it, it works even though the class doesn't have a bean property with the name idFlag according to the JavaBeans spec. But now I'm writing two lines of code when all I needed was one line using the logic:equals tag from the Struts library. I know an additional line of code is not the end of the world but which is better practice? Is having Struts tags and JSTL tags in your JSP bad practice? Could it cause confusion to other developers down the road? In general, using more than one tag library from different sources in a JSP application is not bad practice (it's commonly needed, actually). But I recommend sticking to JSTL in the cases where there's a direct replacement for the Struts tag, as in the case of logic:equals vs. c:if. Back to my point of JSTL being inconsistent... I have this standalone tag in my JSP (with no bean define or c:set and I do not get an exception from this tag... It works just fine c:forEach var=assetType items=${summaryForm.assetTypeQueues} What's confusing and inconsistent is that I didn't need to define the 'summaryForm' object. It was capable of seeing it and extracted the variable I asked from it just fine. Why doesn't the c:if tag act in the same manner? Is this a bug or am I doing something wrong? See above. It's arguably a bug in your bean class (unless there's something else going on here that I'm not aware of). I apologize for the novel I just wrote but I didn¹t want to leave out any details. Any advice
Re: JSTL Tag in a directive.
you can use c:import instead of %@ include, i think that would solve your problem. nick On Sat, 5 Jul 2003, Rick Ross wrote: I can't seem to get this to work: %@ includes file=c:out value='${includePage}' / % I didn't see anything in the Spec that suggests that it would violate spec, but it wasn't mentioned either (as far as I saw.) Since I need the contents of includePage to be processed as JSP, I think I am SOL and will have to wrap it in a choose/when tag c:choose c:when test=${includePage == 'somepage.jsp' %@ includes file=somepage.jsp % /c:when /c:choose Am I missing something? The reference is always local, but when I tried c:import It wouldn't process the JSTL tags in somepage.jsp. I appreciate any feedback Rick - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JSTL Tag in a directive.
Rick Ross wrote: I can't seem to get this to work: %@ includes file=c:out value='${includePage}' / % I didn't see anything in the Spec that suggests that it would violate spec, but it wasn't mentioned either (as far as I saw.) Rick, time to read a good book about JSP ;-) There are two ways to include files defined by the JSP spec, and JSTL adds a third. The include directive you're using here is a staticly including content. It works just like an #include in C, and is processed when the JSP page is turned into a servlet. Hence, the file name is fixed; you can't define it as a dynamic value, not even if you use correct syntax (tags can never be used as attribute values) ;-) Since I need the contents of includePage to be processed as JSP, I think I am SOL and will have to wrap it in a choose/when tag c:choose c:when test=${includePage == 'somepage.jsp' %@ includes file=somepage.jsp % /c:when /c:choose Am I missing something? The reference is always local, but when I tried c:import It wouldn't process the JSTL tags in somepage.jsp. I appreciate any feedback You can either use the standard jsp:include tag: jsp:include page=%= includePage % / or the JSTL c:import tag: c:import url=${includePage} / The main differences are that you must use a Java expression as the attribute value for jsp:include in JSP 1.2 (in JSP 2.0, you can use an EL expression) and that the semantics for c:import are better defined for error cases (e.g., page not found). c:import is also able to include data from external resources, like a different web app in the same server or even from a different server; jsp:include only support include of resources in the same web app. Hope this helps, 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JSTL Tag in a directive.
I think I missed an important point, see intermixed below. Hans Bergsten wrote: Rick Ross wrote: I can't seem to get this to work: %@ includes file=c:out value='${includePage}' / % I didn't see anything in the Spec that suggests that it would violate spec, but it wasn't mentioned either (as far as I saw.) Rick, time to read a good book about JSP ;-) There are two ways to include files defined by the JSP spec, and JSTL adds a third. The include directive you're using here is a staticly including content. It works just like an #include in C, and is processed when the JSP page is turned into a servlet. Hence, the file name is fixed; you can't define it as a dynamic value, not even if you use correct syntax (tags can never be used as attribute values) ;-) Since I need the contents of includePage to be processed as JSP, I think I am SOL and will have to wrap it in a choose/when tag c:choose c:when test=${includePage == 'somepage.jsp' %@ includes file=somepage.jsp % /c:when /c:choose Am I missing something? The reference is always local, but when I tried c:import It wouldn't process the JSTL tags in somepage.jsp. Do you declare the JSTL tag libraries in somepage.jsp? A dynamically included/imported page is processed as a completely separate entity, so it doesn't know about any tag library declarations you've made in the importing page. I appreciate any feedback You can either use the standard jsp:include tag: jsp:include page=%= includePage % / or the JSTL c:import tag: c:import url=${includePage} / The main differences are that you must use a Java expression as the attribute value for jsp:include in JSP 1.2 (in JSP 2.0, you can use an EL expression) and that the semantics for c:import are better defined for error cases (e.g., page not found). c:import is also able to include data from external resources, like a different web app in the same server or even from a different server; jsp:include only support include of resources in the same web app. Hope this helps, 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]