- This topic has 14 replies, 5 voices, and was last updated 20 years, 4 months ago by Skip Hollowell.
-
AuthorPosts
-
andersMemberIn most of my JSPs I use taglibs like this:
<%@ taglib uri=”/tags/struts-html” prefix=”html” %>
<%@ taglib uri=”/tags/struts-bean” prefix=”bean” %>
<%@ taglib uri=”/tags/struts-logic” prefix=”logic” %>in a file I have called ‘wwds.web.xml.template’ I have included the location of my taglibs as the following shows:
<!– Struts Tag Library Descriptors –>
<taglib>
<taglib-uri>/tags/struts-bean</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location>
</taglib><taglib>
<taglib-uri>/tags/struts-html</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-html.tld</taglib-location>
</taglib><taglib>
<taglib-uri>/tags/struts-logic</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-logic.tld</taglib-location>
</taglib>My questions are:
1) Is it ok that I have named my file (‘wwds.web.xml.template’) something other than ‘web.xml’?
2) Does this file have to be placed in the ‘WEB-INF’ folder?
3) In the project properties – java build path – where should I add the file (‘wwds.web.xml.template’) …. under the source tab or under the libraries tab??The reason why I’m asking is that the code assist (Ctrl+space bar) in JSPs don’t work unless I remove these three lines:
<%@ taglib uri=”/tags/struts-html” prefix=”html” %>
<%@ taglib uri=”/tags/struts-bean” prefix=”bean” %>
<%@ taglib uri=”/tags/struts-logic” prefix=”logic” %>I’m using the following:
Windows XP version 2002
Eclipse 3.0M9
-Freshly installed for MyEclipse
MyEclipse 3.8 beta-1
JDK 1.4.1
Riyad KallaMemberI’m pretty sure making up names for web.xml doesn’t help anyone, let along our parser in the JSP editor 😀
I’ve asked a dev to look at this to give you more detailed answers.
support-michaelKeymaster1) Is it ok that I have named my file (‘wwds.web.xml.template’) something other than ‘web.xml’?
The J2EE spec requires the deployment descriptor to be named web.xml.
2) Does this file have to be placed in the ‘WEB-INF’ folder?
Yes, also specified by the J2EE spec.
3) In the project properties – java build path – where should I add the file (‘wwds.web.xml.template’) …. under the source tab or under the libraries tab??
You need the <taglib> entries in your web.xml file or you must use a fancy XML include mechanism (slips my mind how to do it).
A quick note if your using JSP1.2 – which I assume you are – the TLD resolution policy allows you to specify in your JSP <%taglib%> directive the uri location as either a webapp relative path to the TLD or a system identifier of the TLD. This enables you to omit the <taglib> entry in your web.xml file
So try this:
1) remove or comment out <taglib> entries in web.xml if they exist
2) replace JSP taglib directives with 1 of the following forms (your preference):Version-1 – System TLD references:
<%@ taglib uri=”http://jakarta.apache.org/struts/tags-bean” prefix=”bean” %>
<%@ taglib uri=”http://jakarta.apache.org/struts/tags-html” prefix=”html” %>
<%@ taglib uri=”http://jakarta.apache.org/struts/tags-logic” prefix=”logic” %>Version-2 – absolute TLD references
<%@ taglib uri=”/WEB-INF/tld/struts-bean.tld” prefix=”bean” %>
<%@ taglib uri=”/WEB-INF/tld/struts-html.tld” prefix=”html” %>
<%@ taglib uri=”/WEB-INF/tld/struts-logic.tld” prefix=”logic” %>
snpeMemberWhy myeclipse don’t find all tld files in all libraries in WEB-INF/lib, cache it
and use suggested prefix if nothing exists in web.xml
(I don’t know but I think that is in JSP 2.0/servlet 2.4 specification)I don’t use taglib directive anywhere – all is in tld files
regards
Riyad KallaMemberWhy myeclipse don’t find all tld files in all libraries in WEB-INF/lib, cache it
and use suggested prefix if nothing exists in web.xmlIf I understand you correctly, it does. For example, if you add Struts.jar to your build path, you can use the Struts taglibs and not make any entries in your web.xml file.
snpeMemberI don’t use struts – JSF (myfaces) have all like struts and more …
Execpt this, all is correct .
I don’t use include for taglib in any page, too.
All taglib directives are in one prelude file and this file tomcat 5 add automaticregards
support-michaelKeymasterWhy myeclipse don’t find all tld files in all libraries in WEB-INF/lib, cache it
and use suggested prefix if nothing exists in web.xml
(I don’t know but I think that is in JSP 2.0/servlet 2.4 specification)ME’s JSP editor supports the JSP1.2 spec. We have not completed the JSP2 upgraded yet (gazillion changes required). Per the JSP1.2 spec ME will search for explicit TLD’s anywhere under the /WEB-INF directory except for the classes and lib dirs and for packaged taglibs in the /WEB-INF/lib. Works great when using taglib directives with uri=<system identifier>
snpeMemberprelude file is from 2.4 specification, but tld definition in tld libraries is from JSP 1.2
This is part of myfaces-ext.tld – I haven’t to special definition in web.xml<!DOCTYPE taglib PUBLIC “-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN” “http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd”>
<taglib xmlns=”http://java.sun.com/JSP/TagLibraryDescriptor”><tlib-version>0.9.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>MyFaces Extensions</short-name>
<uri>http://myfaces.sourceforge.net/tld/myfaces_ext_0_9.tld</uri>
<description>
Enhanced standard JSP actions and custom MyFaces actions.
</description>…
But, it isn’t important specification – You can only get tld definition from libraries if excists and do code assists
regards
andersMemberThanks a lot for all the feedback, it helped a lot.
Version-1 – System TLD references:
<%@ taglib uri=”http://jakarta.apache.org/struts/tags-bean” prefix=”bean” %>
<%@ taglib uri=”http://jakarta.apache.org/struts/tags-html” prefix=”html” %>
<%@ taglib uri=”http://jakarta.apache.org/struts/tags-logic” prefix=”logic” %>I tried that and it worked – I can now use code assist in my JSPs ***WAYHAY***
However, before I tried the solution mentioned above I tried to add my taglib entries to my web.xml file but that didn’t help … I still couldn’t use code assist …. any idea why???
I have got the Struts.jar on my build path, so is there something else I’m missing???
Once again, thanks for the prompt response.
Cheers.
Anders
Riyad KallaMemberAnders,
Are you using the 1.1 Struts build or a nightly build? In the nightly builds the URI for the taglibs all changed to struts.apache.org/tags-XXXX, so if you entered the URIs above into your web.xml and tried to use them, it confuses the parser.If you are using 1.1 (especially what we ship with) and you still didn’t get autocomplete, then that is odd. I am not able to reproduce that on my end.
Skip HollowellMemberSo what is the official ME recommendation for taglibs? All of my struts apps have the TLD defined in the WEB.XML.
<taglib>
<taglib-uri>struts-bean</taglib-uri>
<taglib-location>/WEB-INF/tags/struts-bean.tld</taglib-location>
</taglib>And in each of my pages, I reference thistaglib-uri as such:
<%@ taglib uri=”struts-bean” prefix=”bean” %>And I get the tag errors and inoperative code completion, although forcing it with CTRL-Space works. I really don’t want to have to change my web xml and all my pages, but if I have to, so be it. Answers and solutions would be greatly appreciated. I can always go back to Eclipse 2.x and the appropriate ME.
Riyad KallaMemberSo what is the official ME recommendation for taglibs?
There isn’t one. We support all taglib references that are deemed valid by the spec.
All of my struts apps have the TLD defined in the WEB.XML.
This is fine, you have simply added new URI mappings instead of the default ones that are included in the struts.jar file (open it up, and go into the META-INF directory inside of the JAR, and then the tlds dir I believe, you will see the tld files and URIs that ME will use IF you do not specify your own, in this case, you specified your own… no biggie).
And in each of my pages, I reference thistaglib-uri as such:
That’s fine.
And I get the tag errors and inoperative code completion, although forcing it with CTRL-Space works.
I don’t know what errors you are talking about, can you paste them here or into a new subject for us to look at? Also if ‘forcing’ completion with CTRL-Space works, then it works. Currently you must use ctrl-space to invoke the autocomplete, but we have an open enhancement request for it popping up automatically. I think a reson for this decision is that the computing required to parse the JSP page on the fly to generate valid completions is quite expensive, so we try and minimize the parsing lag if we can.
Skip HollowellMemberThanks for clearing up the autocomplete. Different than V2, but I prefer it this new way. Much less distracting, not to mention system intensive, as you point out.
Here is a very small sample page…pretty straightforward. I have prepended with line numbers for reference.
1 <%@ taglib uri=”/struts-bean” prefix=”bean”%>
2 <%@ taglib uri=”/struts-html” prefix=”html”%>
3 <bean:message key=”html.doctype”/>
4 <html:html>
5 <link rel=”stylesheet” href=”<html:rewrite page=”/default.css”/>” type=”text/css”/>
6 <head>
7 <title><bean:message key=”title.accessdenied”/></title>
8 </head>
9 <body>
10 <bean:message key=”heading.accessdenied”/>
11 <bean:message key=”text.page.disclaimer”/>
12 </body>
13 </html:html>Here are the error messages I receive from ME. I receive these on every page I have: 1067 now for 1 app. While everything still runs and compiles, I fear I may miss actual valid error as they arise.
Error: bean:message is not recognized! – column 1 (line 3)
Error: ‘html:html’ is not recognized! – column 1 (line 4)
Error: bean:message is not recognized! – column 8 (line 7)
Error: bean:message is not recognized! – column 1 (line 10)If this is something I am mucking up, I would love to know what it is, but like I said, these have never registered errors inside ME before.
Riyad KallaMemberWhat happens when you don’t put a slash in your uri in your JSP page? e.g.: struts-bean, instead of /struts-bean… also you can try removing all of your web.xml TLD entries (just comment them out or osmething) then go into one JSP page, and then create a new JSP page using the File > New > JSP Page > JSP Page Template with Struts 1.1 (name might be different), and then copy the taglib tags from the top of that file into your JSP page, and save it… does it compile without errors?
Skip HollowellMember[Just a thought before getting into the response. I am on RC3, and later today V3 of eclipse. Any issues? Am I attempting to be too far ahead of the curve here? Like I said, the app works, the debug works, everything works, except the taglib errors.]
Taking the slash out of the JSP page will then make my tld file un-findable. I did miss type what my web.xml had from before. The correct entry for the struts-bean is as follows:
<taglib>
<taglib-uri>/struts-bean</taglib-uri>
<taglib-location>/WEB-INF/tags/struts-bean.tld</taglib-location>
</taglib>Once the / is removed from the jsp, the bean tags become unhighligthed, meaning eclipse no longer sees them as tags, but rather they are marked as invalid HTML.
I tried this on a clean project, created by the wizard, and noticed that if I create a default struts app, there is no taglib entry in the web.xml, and the tld files are in the WEB-INF directory.
From what I read here, are some people able to have their .tld files somwhere other than in WEB-INF, and reference them with something other and a fully qualified http:// uri?
-
AuthorPosts