Re: JSTL x:parse problems
I think you're problem is that xmlText expects String. Have you tried xmlURL, isntead of xmlText. here is the way I use parse, which works fine. c:set var=xmlurlsample.xml/c:set x:parse var=dom c:import url=${xmlurl}/ /x:parse peter lin Steve Appling wrote: I am having problems using the standard tag library x:parse tag using a reader. The JSTL spec says that the xmlText attribute can take either a String or a Reader. I am trying the following: % InputStream is = application.getResourceAsStream(/test.xml); InputStreamReader reader = new InputStreamReader(is); % x:parse xmlText=${reader} var=doc/ This results in the following exception: javax.servlet.ServletException: The xmlText attribute illegally evaluated to null or in parse Does anyone know how to do this? If anyone from the expert group is monitoring this, it would be really nice if there were usage examples for each of the tags. Also in the 1.0 Public Draft ALL of the examples provided for x:parse are wrong, they use an older syntax with a source attribute which is not allowed now. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: JSTL x:parse problems
In section 11.2 of the JSTL 1.0 public draft specification it says that xmlText can take a String or a Reader. I can't use xmlUrl (or body content of the parse tag) because my xml is in a section of the web application that is in a restricted security domain. I can't provide authentication information in the url to use xmlUrl. I probably can read the entire document into a single String myself, then use that in xmlText, but that seems somewhat silly. If it really can take a Reader as the documentation states, then I would rather use that approach - I was hoping there was something simple I was missing that was keeping this from working. - Original Message - From: peter lin [EMAIL PROTECTED] To: Tag Libraries Users List [EMAIL PROTECTED] Sent: Thursday, April 18, 2002 8:42 AM Subject: Re: JSTL x:parse problems I think you're problem is that xmlText expects String. Have you tried xmlURL, isntead of xmlText. here is the way I use parse, which works fine. c:set var=xmlurlsample.xml/c:set x:parse var=dom c:import url=${xmlurl}/ /x:parse peter lin Steve Appling wrote: I am having problems using the standard tag library x:parse tag using a reader. The JSTL spec says that the xmlText attribute can take either a String or a Reader. I am trying the following: % InputStream is = application.getResourceAsStream(/test.xml); InputStreamReader reader = new InputStreamReader(is); % x:parse xmlText=${reader} var=doc/ This results in the following exception: javax.servlet.ServletException: The xmlText attribute illegally evaluated to null or in parse Does anyone know how to do this? If anyone from the expert group is monitoring this, it would be really nice if there were usage examples for each of the tags. Also in the 1.0 Public Draft ALL of the examples provided for x:parse are wrong, they use an older syntax with a source attribute which is not allowed now. -- 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: JSTL x:parse problems
The code that handles it does perform type checking, so it should work. the code below is taken from the parsesupport. if (xmlUrl != null) d = parseURLWithFilter(xmlUrl, filter); else { if (xmlText instanceof String) d = parseStringWithFilter((String) xmlText, filter); else if (xmlText instanceof Reader) d = parseReaderWithFilter((Reader) xmlText, filter); else throw new JspTagException( Resources.getMessage(PARSE_INVALID_SOURCE)); } can you post and example of the XML, it could be the XML isn't valid. peter Steve Appling wrote: In section 11.2 of the JSTL 1.0 public draft specification it says that xmlText can take a String or a Reader. I can't use xmlUrl (or body content of the parse tag) because my xml is in a section of the web application that is in a restricted security domain. I can't provide authentication information in the url to use xmlUrl. I probably can read the entire document into a single String myself, then use that in xmlText, but that seems somewhat silly. If it really can take a Reader as the documentation states, then I would rather use that approach - I was hoping there was something simple I was missing that was keeping this from working. - Original Message - From: peter lin [EMAIL PROTECTED] To: Tag Libraries Users List [EMAIL PROTECTED] Sent: Thursday, April 18, 2002 8:42 AM Subject: Re: JSTL x:parse problems I think you're problem is that xmlText expects String. Have you tried xmlURL, isntead of xmlText. here is the way I use parse, which works fine. c:set var=xmlurlsample.xml/c:set x:parse var=dom c:import url=${xmlurl}/ /x:parse peter lin Steve Appling wrote: I am having problems using the standard tag library x:parse tag using a reader. The JSTL spec says that the xmlText attribute can take either a String or a Reader. I am trying the following: % InputStream is = application.getResourceAsStream(/test.xml); InputStreamReader reader = new InputStreamReader(is); % x:parse xmlText=${reader} var=doc/ This results in the following exception: javax.servlet.ServletException: The xmlText attribute illegally evaluated to null or in parse Does anyone know how to do this? If anyone from the expert group is monitoring this, it would be really nice if there were usage examples for each of the tags. Also in the 1.0 Public Draft ALL of the examples provided for x:parse are wrong, they use an older syntax with a source attribute which is not allowed now. -- 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: JSTL x:parse problems
Reader is fine... Your problem comes from a simple error that everyone (including me) makes from time to time when testing JSTL with scriptlets. Look at your sample carefully: % InputStream is = application.getResourceAsStream(/test.xml); InputStreamReader reader = new InputStreamReader(is); % x:parse xmlText=${reader} var=doc/ You've just created a scripting variable called reader, but nothing ties this scripting variable to a scoped attribute, so ${reader} *is* null. If you add a call like pageContext.setAttribute(reader, reader), the problem will go away. Of course, this particular sample would be better without a scriptlet, as c:import url=/test.xml varReader=xml/ x:parse xml=${xml} var=doc/ /c:import but I assume that your scriptlet was just an example of Reader, not the end-to-end intended use. :-) Hope that helps, -- Shawn Bayern Author, JSP Standard Tag Library http://www.jstlbook.com (coming this summer from Manning Publications) On Thu, 18 Apr 2002, Steve Appling wrote: In section 11.2 of the JSTL 1.0 public draft specification it says that xmlText can take a String or a Reader. I can't use xmlUrl (or body content of the parse tag) because my xml is in a section of the web application that is in a restricted security domain. I can't provide authentication information in the url to use xmlUrl. I probably can read the entire document into a single String myself, then use that in xmlText, but that seems somewhat silly. If it really can take a Reader as the documentation states, then I would rather use that approach - I was hoping there was something simple I was missing that was keeping this from working. - Original Message - From: peter lin [EMAIL PROTECTED] To: Tag Libraries Users List [EMAIL PROTECTED] Sent: Thursday, April 18, 2002 8:42 AM Subject: Re: JSTL x:parse problems I think you're problem is that xmlText expects String. Have you tried xmlURL, isntead of xmlText. here is the way I use parse, which works fine. c:set var=xmlurlsample.xml/c:set x:parse var=dom c:import url=${xmlurl}/ /x:parse peter lin Steve Appling wrote: I am having problems using the standard tag library x:parse tag using a reader. The JSTL spec says that the xmlText attribute can take either a String or a Reader. I am trying the following: % InputStream is = application.getResourceAsStream(/test.xml); InputStreamReader reader = new InputStreamReader(is); % x:parse xmlText=${reader} var=doc/ This results in the following exception: javax.servlet.ServletException: The xmlText attribute illegally evaluated to null or in parse Does anyone know how to do this? If anyone from the expert group is monitoring this, it would be really nice if there were usage examples for each of the tags. Also in the 1.0 Public Draft ALL of the examples provided for x:parse are wrong, they use an older syntax with a source attribute which is not allowed now. -- 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]
Extending jsp:useBean tag
I am interested in extending jsp:useBean tag. I want to add product specific calls to code within this tag, which are always performed. What is the best way to accomplish this. Should I implement all function done by jsp:useBean in the new tag or is there a way to extend the existing TagHandler class for this tag. How do I find that tag handler class? Asha Mishra, Project Lead, Commerce Models WebSphere Commerce Suite IBM Canada Ltd., A2-710 8200 Warden Avenue Markham, ON L6G 1C7 Phone: (905)413-4223 (T/L 969) Fax (905) 413-4751 e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Extending jsp:useBean tag
On Thu, 18 Apr 2002 [EMAIL PROTECTED] wrote: I am interested in extending jsp:useBean tag. I want to add product specific calls to code within this tag, which are always performed. What is the best way to accomplish this. Should I implement all function done by jsp:useBean in the new tag or is there a way to extend the existing TagHandler class for this tag. How do I find that tag handler class? Since jsp:useBean is a JSP standard action, it's generally implemented within a container, not using the tag extension protocol (e.g., the Tag interface, which I think is what you mean by TagHandler). Thus, to implement its function portably, you'd need to write it from scratch. If you're interested only in the part of its functionality that affects scoped variables, you can look at the handler for c:set in the JSTL reference implementation. I've written code like that handler to be as general and instructive as possible, so it might help. -- Shawn Bayern Author, 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: JSTL x:parse problems
On Thu, 18 Apr 2002, Steve Appling wrote: Thank you Shawn! I had hoped I was just doing something stupid. Unfortunately that isn't the only thing I'm doing wrong - this just moved me to my next problem. Here's a simplified example- ignoring the reader code I have: x:parse xmlText=${reader} var=doc/ x:out select=$doc/action/ That does indeed look right. Can I see the SAXPathException you're getting, as well as pehaps an entire page, in context? The following, just as a reference, works correctly: %@ taglib uri=http://java.sun.com/jstl/core; prefix=c % %@ taglib prefix=x uri=http://java.sun.com/jstl/xml; % c:import url=foo.xml varReader=reader x:parse xml=${reader} var=doc/ /c:import x:out select=$doc/root/action/ where he file foo.xml contains your sample document: root action title=First Action This is my first action. /action /root Note, by the way, that to access the 'action' element, you'll need to use the expression $doc/root/action, not $doc/action. $doc refers to the document (logically the document root node), not the root element (which is logically a child of that node). But that wouldn't lead to an exception, just an empty result. -- Shawn Bayern Author, 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: JSTL x:parse problems
After scrolling down in the exception list I found that the root cause is a NoClassDefFoundError. What is the org.saxpath package? I'll post my simple sample page if needed, but does the following exception report shed any light on the problem? Exception Report: javax.servlet.ServletException: org/saxpath/SAXPathException at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:514) 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:215) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:2 46) 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.StandardContext.invoke(StandardContext.java:2366) 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.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.http10.HttpProcessor.process(HttpProcessor.jav a:676) at org.apache.catalina.connector.http10.HttpProcessor.run(HttpProcessor.java:79 9) at java.lang.Thread.run(Thread.java:484) Root Cause: java.lang.NoClassDefFoundError: org/saxpath/SAXPathException at java.lang.Class.getMethods0(Native Method) at java.lang.Class.getDeclaredMethods(Class.java:1039) at java.beans.Introspector$1.run(Introspector.java:852) at java.security.AccessController.doPrivileged(Native Method) at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:850) at java.beans.Introspector.getTargetEventInfo(Introspector.java:556) at java.beans.Introspector.getBeanInfo(Introspector.java:294) at java.beans.Introspector.(Introspector.java:271) at java.beans.Introspector.getBeanInfo(Introspector.java:81) at org.apache.jasper.compiler.TagCache.setTagHandlerClass(TagCache.java:116) at org.apache.jasper.compiler.TagBeginGenerator.init(TagBeginGenerator.java:146 ) at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.init(JspPa rseEventListener.java:978) at org.apache.jasper.compiler.JspParseEventListener.addGenerator(JspParseEventL istener.java:151) at org.apache.jasper.compiler.JspParseEventListener.handleTagBegin(JspParseEven tListener.java:1188) at org.apache.jasper.compiler.DelegatingListener.handleTagBegin(DelegatingListe ner.java:217) at org.apache.jasper.compiler.DelegatingListener.handleTagBegin(DelegatingListe ner.java:212) at org.apache.jasper.compiler.Parser$Tag.accept(Parser.java:845) at org.apache.jasper.compiler.Parser.parse(Parser.java:1132) at org.apache.jasper.compiler.Parser.parse(Parser.java:1091) at org.apache.jasper.compiler.Parser.parse(Parser.java:1087) at org.apache.jasper.compiler.ParserController.parse(ParserController.java:213) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:210) at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:576) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspSe rvlet.java:179) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja va:209) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:414) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:506) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
Re: JSTL x:parse problems
Oh! That just means you're missing a dependency in your web application. The easiest instructions, for right now, are to make sure all the JARs in the standard-example.war distribution are in your own web application's WEB-INF/lib directory. I'll be clarifying and simplifying the installation process in the upcoming Beta2 release based on advice from Hans Bergsten and others on taglibs-dev. -- Shawn Bayern Author, JSP Standard Tag Library http://www.jstlbook.com (coming this summer from Manning Publications) On Thu, 18 Apr 2002, Steve Appling wrote: After scrolling down in the exception list I found that the root cause is a NoClassDefFoundError. What is the org.saxpath package? I'll post my simple sample page if needed, but does the following exception report shed any light on the problem? Exception Report: javax.servlet.ServletException: org/saxpath/SAXPathException at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:514) 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:215) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:2 46) 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.StandardContext.invoke(StandardContext.java:2366) 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.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.http10.HttpProcessor.process(HttpProcessor.jav a:676) at org.apache.catalina.connector.http10.HttpProcessor.run(HttpProcessor.java:79 9) at java.lang.Thread.run(Thread.java:484) Root Cause: java.lang.NoClassDefFoundError: org/saxpath/SAXPathException at java.lang.Class.getMethods0(Native Method) at java.lang.Class.getDeclaredMethods(Class.java:1039) at java.beans.Introspector$1.run(Introspector.java:852) at java.security.AccessController.doPrivileged(Native Method) at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:850) at java.beans.Introspector.getTargetEventInfo(Introspector.java:556) at java.beans.Introspector.getBeanInfo(Introspector.java:294) at java.beans.Introspector.(Introspector.java:271) at java.beans.Introspector.getBeanInfo(Introspector.java:81) at org.apache.jasper.compiler.TagCache.setTagHandlerClass(TagCache.java:116) at org.apache.jasper.compiler.TagBeginGenerator.init(TagBeginGenerator.java:146 ) at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.init(JspPa rseEventListener.java:978) at org.apache.jasper.compiler.JspParseEventListener.addGenerator(JspParseEventL istener.java:151) at org.apache.jasper.compiler.JspParseEventListener.handleTagBegin(JspParseEven tListener.java:1188) at org.apache.jasper.compiler.DelegatingListener.handleTagBegin(DelegatingListe ner.java:217) at org.apache.jasper.compiler.DelegatingListener.handleTagBegin(DelegatingListe ner.java:212) at org.apache.jasper.compiler.Parser$Tag.accept(Parser.java:845) at org.apache.jasper.compiler.Parser.parse(Parser.java:1132) at org.apache.jasper.compiler.Parser.parse(Parser.java:1091) at org.apache.jasper.compiler.Parser.parse(Parser.java:1087) at org.apache.jasper.compiler.ParserController.parse(ParserController.java:213) at
Re: JSTL x:parse problems
Thank you - I was under the mistaken impression that jstl.jar and standard.jar contained the entire JSTL implementation (at least what wasn't already in Tomcat's common lib). That definitely needs to make it into the documentation. BTW, in the example you sent you had: x:parse xml=${reader} var=doc/ In my version, the attribute for the parse action needs to be xmlText. Was that a typo or are you using a different version than I am? Also I was not aware that I could get a reader from the import action with: c:import url=foo.xml varReader=reader That's cool! -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: JSTL x:parse problems
On Thu, 18 Apr 2002, Steve Appling wrote: BTW, in the example you sent you had: x:parse xml=${reader} var=doc/ In my version, the attribute for the parse action needs to be xmlText. Was that a typo or are you using a different version than I am? Also I was not aware that I could get a reader from the import action with: c:import url=foo.xml varReader=reader This changed between Public Draft (PD) and Proposed Final Draft (PFD). The build over the last few days reflects the new usage. 'varReader' has indeed long been an attribute for c:import. In many cases, it'll perform better than 'var', though for relative URLs like foo.xml, it won't make any difference performance-wise. -- Shawn Bayern Author, 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]
question about XPath tests
I have a node in an XML doc I'd like to compare against. It's a number, say 1001. x:out select=$dom_ref/path/to/node = 1001/ displays true or false correctly depending on if the the node content is 1001 or not. But this always is true: x:if select=$dom_ref/path/to/node = 1001true/x:if no matter what is in the node. I can use x:set to set a variable and compare with c:if but that's a pain. Am I missing something in the syntax? Is it comparing it with the string true? -Steve -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]