- This topic has 16 replies, 3 voices, and was last updated 21 years ago by Scott Anderson.
-
AuthorPosts
-
david32MemberHi,
I can’t use the variable tag in my tld without it causing a load of errors. As in if I use the variable tag I get the following errors.The method getPageContext(Servlet, ServletRequest, ServletResponse, String, boolean, int, boolean) in the type JspFactory is not applicable for the arguments (_capsum$002ejsp$, HttpServletRequest, HttpServletResponse, null, boolean, int, boolean)
and
The method getServletConfig() is undefined for the type _capsum$002ejsp$
and
numPats cannot be resolved
NumPats is the variable
If I ignore these errors I can deploy on Weblogic 6.1 and my code works.I’m using eclipse Version: 2.1.2
Build id: 200311030802and MyEclipse
Version: 2.6.4
Build id: 200311041200Dave
Riyad KallaMemberDavid,
Can you post the file giving you trouble? These generic Jsp-related errors… especially the ones where you will change one thing, then get like 8 errors in your tasks list almost ALWAYS suggest a busted JSP page (not well formed, missing semicolon, stuff like that). Sometimes I find (acutally about 25% of the time) if I recompile my entire project, the errors go away.So maybe do this:
1) Recompile all JSPs in project (right click on project root, MyEclipse->Recompile All JSPs)
2) If that doesn’t work, post the JSP that is giving you hastle and we’ll take a look at it together.
david32MemberI’ll see if I’ve time to create a smaller jsp with the same error. I have tried recompiling all the jsps. And I moved away from thinking my jsp was incorrect as when deloyed it works as expected in weblogic 6.1.
I take it no one else has had a problem use the variable tag in there tld then?Dave
Riyad KallaMemberI’m not totally clear what you mean by “variable tag”… can you cut-paste the line that is an example of what you want? Is this a J2EE 1.4 thing? Scott can probably help you, I’m just someone that has extra time on his hands to help out 🙂
david32MemberSorry I suppose variable tag is a bit vague, there’s only on in the tld as far as I know though. Here is an example of it in use
I’ll try get a jsp page together later, but basically it just references this variable.<?xml version="1.0"?> <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd"> <taglib> <tlib-version>1.0</tlib-version> <jsp-version>1.2</jsp-version> <short-name>cTag</short-name> <tag> <name>CustomTag</name> <tag-class>com.company.package.CustomTag</tag-class> <body-content>JSP</body-content> <variable> <name-given>numPats</name-given> <variable-class>java.lang.Integer</variable-class> <scope>NESTED</scope> </variable> </tag> </taglib>
Riyad KallaMemberThis looks sane to me… so you have this in a TLD file (mytags.tld for example) and reference in your web.xml with a URI, and then in your JSP you add a taglib entry at the top with the given URI, and THEN you get a tone of errors and can’t use your custom taglib? Is this an accurate description of your problem?
If you aren’t mentioning this TLD in your web.xml, you need to. Also I’m not sure how farmiliar with taglibs you are, but I’m guessing pretty farmiliar since you seem to be writing your own, so I won’t suggest that you should add the taglib entry at the top of the JSP you want to use it in 😉
david32MemberAs I mentioned before I can deploy the code on WebLogic and it works fine. So it just seems to be the MyEclipse JSP editor is having some trouble with the variable tag in the tld. It doesn’t seem to read variables that are mentioned in it and therefore says they are undefined etc… maybe this is just something MyEclipse can’t do?
Dave
Riyad KallaMemberdamnit all… I just typed out a huge reply and accidentaly killed it… anyway here is the summary:
1) I’m not surprised it works in WebLogic, MyEclipse requires the tld to be defined in your xml and proper taglib entries to be in the JSP. If you don’t have these, you might need to add them to get them working.
2) Other people have had problems with TLDs and they were because of missing web.xml entries or J2EE 1.4 style usage of the taglibs which aren’t supported yet.So if you could let me know if you have these entries we can figure out if we should (a) keep trouble shooting the problem or (b) jump ship and let scott hop in here and really help 🙂
david32MemberOh I think Weblogic also requires those entries and they are there. I’m using Weblogic 6.1 so no fancy stuff JSP 1.2 and J2EE 1.3.
Riyad KallaMemberHmm ok well then it seems 3 of the 4 parts are in order (tld, class files, web.xml entries) I will wait until you get a chance to put together a test JSP and post it…
easy way->
1) File->New->JSP Page
2) Add your taglib entry at top of JSP
3) Go down into file and try and use taglib
4) Save (compile)
david32MemberDidn’t get a chance to put that together. I started looking at NetBeans it can recognise the variables and some. It has great support for tag libs etc… I miss the ease of use of Eclipse though I find it difficult to do alot of the normal stuff.
Any idea when support for the variable tag in the tag lib file will be available and when will we see tag lib editing like in netbeans?
Since it works on everything else I’m assuming MyEclipse just doesn’t support variable tags yet.
Dave
Riyad KallaMemberDave I’m glad to hear Taglib editing worked for you in NetBeans, but as a 3-year veteran of NetBeans, I would only say “give it time”, roughly a week of serious editing before you are riping your hair out trying to figure out why everything is slowly breaking. Its absolute maddening.
I think Scott should hop in here because I just don’t know enough to help, sorry.
Scott AndersonParticipantDave,
Can you update to the 2.7 release and see if it’s still a problem? A lot of work has gone into this release of the JSP editor so hopefully any issues have been resolved.
–Scott
MyEclipse Support
david32MemberHi,
Yep its still a problem. I get less errors. I now only get the numPats cannot be resolved error.
It does pick up the variable from the tld, as that’s the variable name in the error. I take it MyEclipse is meant to support this and I may be doing something wrong? This does work when deployed on Weblogic 6.1 or when loaded into NetBeans.Here is the code
The Jsp
<%@ taglib prefix="test" uri="http://www.company.com/taglibs/TestTagLib" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> This is my JSP page. <br> <test:CustomTag> <%-- Numpats = <%= numPats %> --%> </test:CustomTag> </body> </html>
The taglib
<?xml version="1.0"?> <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd"> <taglib> <tlib-version>1.0</tlib-version> <jsp-version>1.2</jsp-version> <short-name>cTag</short-name> <tag> <name>CustomTag</name> <tag-class>com.company.pack.CustomTag</tag-class> <body-content>JSP</body-content> <variable> <name-given>numPats</name-given> <variable-class>java.lang.Integer</variable-class> <scope>NESTED</scope> </variable> </tag> </taglib>
The tag handler
package com.company.pack; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.TagSupport; public class CustomTag extends TagSupport { public int doStartTag() throws JspException { pageContext.setAttribute("numPats",new Integer(42)); return EVAL_BODY_INCLUDE; } }
And web.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <taglib> <taglib-uri>http://www.company.com/taglibs/TestTagLib</taglib-uri> <taglib-location>/WEB-INF/tlds/testTagLib.tld</taglib-location> </taglib> </web-app>
The get the error on lines 7 and 9.
Dave
Scott AndersonParticipantDave,
Thanks for the great example. I’ll put this in as a bug report so we can fix it in the next release, but let me clear up one more thing. I assume the <taglib-uri> you’re specifying has just been anonymized for the purpose of the example and actually points to a valid, accessible location, right?
–Scott
MyEclipse Support -
AuthorPosts