how to use taglib

i am new to tag library, so if anybody can help me telling how to use tags in jsp. Actually, i am trying a small example with Tomcat 4.1, when i run my jsp file it's gives this error -

--

org.apache.jasper.JasperException: File "/jsp/taglibEx" not found

at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:105)

at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:430)

at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:154)

at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:180)

--

this is a simple file not found exception but i am not able to figure out where to put my .tld file so get rid of it, PLEASE HELP

[773 byte] By [MayankTya] at [2007-11-27 1:56:44]
# 1

You can place ur .tld file any where under WEB-INF,

(That is directly under WEB-INF or in sub folders under WEB-INF)

but u need to give exact path to that .tld ,in ur web.xml file like

<taglib-location>/WEB-INF/.../my.tld</taglib-location>

Message was edited by:

BalajiGaneshReddy

BalajiGaneshReddya at 2007-7-12 1:31:28 > top of Java-index,Java Essentials,Java Programming...
# 2
thanks for the reply Balaji..actually i don't know how to put the path in the web.xml file, so if you can help a bit more..and tell me what exactly to place and where exactly to placethanks,Mayank
MayankTya at 2007-7-12 1:31:28 > top of Java-index,Java Essentials,Java Programming...
# 3

First u install jdk and Tomcat software

ex:

***

c:\jdk1.4

c:\tomcat5.0

set this in ur environment variable..

click new button

and first rowJAVA_HOME

second rowc:\jdk1.4

click again new button

first rowCATALINA_HOME

second rowc:\tomcat5.0

click again new button

first rowCLASSPATH

second row.;%classpath%;c:\tomcat5.0\common\lib\servlet.jar; //what ever u have to store or set classpath ..u just add near by semicolon

create ur own dir under [ c:\tomcat5.0\webapps ]

for ex:

******

c:\tomcat5.0\webapps\sample

under sample dir u have to create WEB-INF(folder or dir)

under WEB-INF dir create

1) lib

2) tlds

3) src

4) classes

lib dir for storing library files

tlds for tag library files

src for java , javabeans,servlets....

classes for all compiled java files..

create one [ web.xml ] file under WEB-INF

copy this below code in web.xml

<?xml version="1.0"?>

<!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>

<!-- Action Servlet Configuration -->

<servlet>

<servlet-name>action</servlet-name>

<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>

<init-param>

<param-name>config</param-name>

<param-value>/WEB-INF/struts-config.xml</param-value>

</init-param>

<load-on-startup>1</load-on-startup>

</servlet>

<!-- Action Servlet Mapping -->

<servlet-mapping>

<servlet-name>action</servlet-name>

<url-pattern>*.do</url-pattern>

</servlet-mapping>

<!-- The Welcome File List -->

<welcome-file-list>

<welcome-file>/index.jsp</welcome-file>

</welcome-file-list>

<!-- Struts Tag Library Descriptors -->

<taglib>

<taglib-uri>/WEB-INF/tlds/struts-bean.tld</taglib-uri>

<taglib-location>/WEB-INF/tlds/struts-bean.tld</taglib-location>

</taglib>

<taglib>

<taglib-uri>/WEB-INF/tlds/struts-html.tld</taglib-uri>

<taglib-location>/WEB-INF/tlds/struts-html.tld</taglib-location>

</taglib>

<taglib>

<taglib-uri>/WEB-INF/tlds/struts-logic.tld</taglib-uri>

<taglib-location>/WEB-INF/tlds/struts-logic.tld</taglib-location>

</taglib>

<!-- user definded Tag Library Descriptors -->

<!-- ***************************************** -->

<taglib>

<taglib-uri>/WEB-INF/tlds/mytaglib.tld</taglib-uri>

<taglib-location>/WEB-INF/tlds/mytaglib.tld</taglib-location>

</taglib>

</web-app>

create struts-config.xml(for struts only)

**********************************************

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"

"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>

<message-resources

parameter="ApplicationResources"/>

<data-sources>

<data-source>

<set-property property="autoCommit" value="true"/>

<set-property property="description" value="Connection Pooling Configuration"/>

<set-property property="driverClass" value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>

<set-property property="maxCount"value="4"/>

<set-property property="minCount"value="2"/>

<set-property property="password"value="ontrack20"/>

<set-property property="url"value="jdbc:microsoft:sqlserver://scalar6:1433;DatabaseName=JAVATEAM;SelectMethod=cursor"/>

<set-property property="user"value="sa"/>

</data-source>

</data-sources>

</struts-config>

sample index.jsp for implementing user definded tags.

********************************************************

<%@ taglib uri="/WEB-INF/tlds/mytaglib.tld" prefix="first" %>

<first:helloparam name="vijaykumar"/>

####after ur program code, compile, restart ur tomcat server run...

drvijayy2k2a at 2007-7-12 1:31:28 > top of Java-index,Java Essentials,Java Programming...