Hi Enrico,<br><br><div class="gmail_quote">On 23 July 2012 15:39, Enrico Ballarin Dolfin <span dir="ltr"><<a href="mailto:enrico@sed.ethz.ch" target="_blank">enrico@sed.ethz.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi Yves,<br>
<div class="im"><br>
On Monday 23 July <a href="tel:2012%2008" value="+352201208">2012 08</a>:55:03 Yves Glodt wrote:<br>
> Hi,<br>
><br>
> here is some example code. You will also find plenty of tutorials on the<br>
> web. The best is you create a "Dynamic Web Project" in Eclipse and play<br>
> around there.<br>
><br>
<br>
</div>many thanks for your suggestion. I'm coming forward and I've experimented a<br>
bit with a separate "Dynamic Web Project" in Eclipse.<br>
<br>
Note that I have moved WebContent/META-INF/yourtags.tld to WebContent/WEB-<br>
INF/yourtags.tld to be able to run it, as I have seen in several tutorials.<br>
<br></blockquote><div><br>ok<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I could run the example as standalone and I have now the Taglib example<br>
running as servlet on tomcat, but I cannot access it from inside my opencms<br>
application:<br>
<br>
---------------------<br>
<div class="im"><%@ page session="true" language="java" contentType="text/html; charset=UTF-8"<br>
pageEncoding="UTF-8"%><br>
</div><%@ taglib prefix="mytags" uri="<a href="http://localhost:8080/HelloWorldTag/WEB-%0AINF/yourtags.tld" target="_blank">http://localhost:8080/HelloWorldTag/WEB-<br>
INF/yourtags.tld</a>" %><br></blockquote><div><br>Try to change the uri to "/WEB-
INF/yourtags.tld". That should help I hope :-)<br><br>Also, I forgot to mention that you need to build a jar from your eclipse project and deploy it to WEB-INF/lib of your OpenCms installation.<br><br>Here is a build-file for ant which I use for this purpose:<br>

<br><br><?xml version="1.0" encoding="UTF-8"?><br><br><project default="buildTaglib" basedir="." name="taglib"><br><br>    <!--<br>    <a href="http://ant.apache.org/manual/CoreTasks/jar.html">http://ant.apache.org/manual/CoreTasks/jar.html</a><br>

    <a href="http://ant.apache.org/manual/tutorial-tasks-filesets-properties.html">http://ant.apache.org/manual/tutorial-tasks-filesets-properties.html</a><br>    <a href="http://snippets.dzone.com/posts/show/1600">http://snippets.dzone.com/posts/show/1600</a><br>

    <a href="http://ant.apache.org/manual/dirtasks.html#directorybasedtasks">http://ant.apache.org/manual/dirtasks.html#directorybasedtasks</a><br>    <a href="http://onlamp.com/pub/a/php/2005/12/20/php_ant.html?page=1">http://onlamp.com/pub/a/php/2005/12/20/php_ant.html?page=1</a><br>

    --><br><br><br><target name="init"><br>    <property name="temp.dir" value="${java.io.tmpdir}/${<a href="http://user.name">user.name</a>}/${<a href="http://ant.project.name">ant.project.name</a>}" /><br>

    <mkdir dir="${temp.dir}" /><br>    <property name="lib.dir" value="WebContent/WEB-INF/lib" /><br>    <property name="src.dir" value="$[basedir}/src" /><br>

    <property name="build.dir" value="${basedir}/ant-build" /><br>    <property name="tld.file" location="./WebContent/META-INF/yourtags.tld" /><br></target><br><br>

<br><target name="compile"><br>    <path id="classpath"><br>        <fileset dir="${lib.dir}" includes="**/*.jar" /><br>        <fileset dir="${basedir}/build-libs" includes="**/*.jar" /><br>

    </path><br>    <javac srcdir="./src" classpathref="classpath" target="1.6" source="1.6" destdir="${temp.dir}"<br>        debug="on"<br>        debuglevel="lines,source"<br>

    /><br></target><br><br><br><target name="jar"><br>    <delete file="hello.jar" /><br>    <property name="version.num" value="1.00" /><br>    <buildnumber file="build.num" /><br>

<br>    <tstamp><br>        <format property="buildTimeStamp" pattern="yyyyMMdd-HHmmss" timezone="Europe/Luxembourg" /><br>    </tstamp><br><br>    <mkdir dir="${temp.dir}/META-INF" /><br>

    <copy file="./WebContent/META-INF/yourtags.tld" todir="${temp.dir}/META-INF" /><br><br>    <manifest file="MANIFEST.MF"><br>        <attribute name="Built-By" value="${<a href="http://user.name">user.name</a>}" /><br>

        <attribute name="Implementation-Version" value="${version.num}-b${build.number}" /><br>        <attribute name="Built-Date" value="${buildTimeStamp}" /><br>    </manifest><br>

<br>    <jar destfile="taglib-${buildTimeStamp}.jar" basedir="${temp.dir}" includes="**/*" manifest="MANIFEST.MF" compress="yes" /><br></target><br><br><br><target name="cleanup"><br>

    <delete dir="${temp.dir}" /><br></target><br><br><br><target name="buildTaglib" depends="init,compile,jar,cleanup" /><br><br><br></project><br><br><br><br><br><br>

<br><br><br><br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
<mytags:HelloWorldTag name="John Doe" /><br>
</div>---------------------<br>
<br>
Accessing in the browser <a href="http://localhost:8080/opencms/opencms/test-tag.jsp" target="_blank">http://localhost:8080/opencms/opencms/test-tag.jsp</a><br>
I'm getting this error:<br>
<br>
The absolute uri: <a href="http://localhost:8080/HelloWorldTag/WEB-INF/yourtags.tld" target="_blank">http://localhost:8080/HelloWorldTag/WEB-INF/yourtags.tld</a><br>
cannot be resolved in either web.xml or the jar files deployed with this<br>
application.<br>
<br>
Do you mean the Taglib has to be run as a separate servlet or do I have to<br>
integrate it inside my opencms application?<br>
<br>
Best regards,<br>
Enrico<br>
<br>
><br>
><br>
> *Save this as WebContent/META-INF/yourtags.tld<br>
<div class="im">> *<br>
> <taglib version="2.0" xmlns="<a href="http://java.sun.com/xml/j2ee" target="_blank">http://java.sun.com/xml/j2ee</a>" xmlns:xsi="<br>
> <a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>" xsi:schemaLocation="<br>
> <a href="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" target="_blank">http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd</a>"><br>
><br>
>     <tlib-version>2.0</tlib-version><br>
>     <jsp-version>2.0</jsp-version><br>
>     <short-name>Tag Library</short-name><br>
>     <uri><a href="http://your.taglib.site.com" target="_blank">http://your.taglib.site.com</a></uri><br>
>     <display-name></display-name><br>
>     <small-icon></small-icon><br>
>     <large-icon></large-icon><br>
>     <description></description><br>
><br>
>     <tag><br>
>         <name>HelloWorldTag</name><br>
>         <tag-class>com.example.tags.HelloWorldTag</tag-class><br>
>         <body-content>empty</body-content><br>
>         <attribute><br>
>             <name>name</name><br>
>             <required>false</required><br>
>             <rtexprvalue>true</rtexprvalue><br>
>             <description>Your Description</description><br>
>         </attribute><br>
>     </tag><br>
><br>
> </taglib><br>
><br>
><br>
><br>
</div>> *Create this class:<br>
<div class="im">> *<br>
> package com.example.tags;<br>
><br>
> import java.io.IOException;<br>
><br>
> import javax.servlet.jsp.tagext.TagSupport;<br>
><br>
> public class HelloWorldTag extends TagSupport {<br>
><br>
>     private static final long    serialVersionUID    = 1L;<br>
>     private String                name                = "";<br>
><br>
><br>
>     public HelloWorldTag() {<br>
>         super();<br>
>     }<br>
><br>
><br>
>     public void setName(final String name) {<br>
>         <a href="http://this.name" target="_blank">this.name</a> = name;<br>
>     }<br>
><br>
><br>
>     @Override<br>
>     public int doStartTag() {<br>
>         return EVAL_PAGE;<br>
>     }<br>
><br>
><br>
>     @Override<br>
>     public int doEndTag() throws javax.servlet.jsp.JspTagException {<br>
>         try {<br>
>             pageContext.getOut().write("<p>Hello " + name + "!</p>");<br>
>         } catch (final IOException e) {<br>
>             e.printStackTrace();<br>
>         }<br>
>         return EVAL_PAGE;<br>
>     }<br>
> }<br>
><br>
><br>
><br>
</div>> *Call the tag from a JSP (which you can place in OpenCms as jsp):<br>
<div class="im HOEnZb">> *<br>
> <%@ page session="true" language="java" contentType="text/html;<br>
> charset=UTF-8" pageEncoding="UTF-8"%><br>
> <%@ taglib prefix="mytags" uri="<a href="http://your.taglib.site.com" target="_blank">http://your.taglib.site.com</a>" %><br>
><br>
> <mytags:HelloWorldTag name="John Doe" /><br>
><br>
><br>
><br>
> Best regards,<br>
> Yves<br>
</div><div class="HOEnZb"><div class="h5">_______________________________________________<br>
This mail is sent to you from the opencms-dev mailing list<br>
To change your list options, or to unsubscribe from the list, please visit<br>
<a href="http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev" target="_blank">http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev</a><br>
<br>
<br>
<br>
</div></div></blockquote></div><br>