• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Not able to use Struts Taglibs

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am new to struts architecture...
I have problem in using taglibs.

I placed all the *.jar files inside webapps\WEB-INF\lib.
I placed struts-html.tld inside \WEB-INF.

In the WEB-INF\web.xml I have placed entry
<taglib>
<taglib-uri>/tags/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>

In my JSP I used:
<%@ taglib uri="/tags/struts-html.tld" prefix="html" %>

while running my JSP i got the following error....
.apache.jasper.JasperException: File "/tags/struts-html.tld" not found
at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:214)
at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:174)

I am using struts 1.1 - pls help me to resolve this....
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to add the following too in web.xml

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>/do/*</url-pattern>
</servlet-mapping>
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or try this in your JSP page:

 
selvi family
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have tried both the ways still getting the same error...

Why its not able to find the struts-html.tld
I gave correct path in my JSP
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

still not working...

Kindly help me ..
 
selvi family
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help me....
 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try to modify the web.xml as



Then in the jsp page use this :--


I am not sure, but give it a try if it helps?
It would be better if you provide the jsp snippet, along with ur's directory structure.
 
selvi family
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have upgraded tomcat from 4.0 to 4.1
I got the similar error :
org.apache.jasper.JasperException: File "/WEB-INF/struts-bean.tld" 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)


My Struts Directory structure:
D:\Tomcat 4.1\webapps\struts
Inside \struts I have \jsp.

\jsp -under \jsp - LoginView.jsp
\WEB-INF
under \WEB-INF all *.tld files
web.xml
struts-config.xml
\lib
under \lib All *.jar files

Entry in Web.xml
<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>

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

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

<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>

JSP Code:
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html>
<head>
<link rel="stylesheet" href="./display/ie.css"/>
<title>><struts:message key="title.login" /></title>
</head>
<body>

<struts:message key="heading.login" />

<fieldset>
<legend>Login Form</legend>
<html:errors />
<html:form action="/login">
<p>
<bean:message key="label.User Name" />:
<html:text property="username" size="10" />
<br>
<bean:message key="label.User Code" />:
<html assword property="usercode" size="10" />
<br><br>
<html:submit>
<bean:message key="button.submit" />
</html:submit>
</html:form>
</fieldset>

</body>
</html>

pls help me soon...I am not able to proceed with struts learning
 
Craig Jackson
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you checked the Tomcat startup console or logs for any error messages or any messages pertaining to your context "struts"?

Maybe displaying your full web.xml might shed some light on the situation?
 
selvi family
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
web.xml :

<?xml version="1.0" encoding="ISO-8859-1"?>

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

<!-- Define servlet-mapped and path-mapped example filters -->
<filter>
<filter-name>Servlet Mapped Filter</filter-name>
<filter-class>filters.ExampleFilter</filter-class>
<init-param>
<param-name>attribute</param-name>
<param-value>filters.ExampleFilter.SERVLET_MAPPED</param-value>
</init-param>
</filter>
<filter>
<filter-name>Path Mapped Filter</filter-name>
<filter-class>filters.ExampleFilter</filter-class>
<init-param>
<param-name>attribute</param-name>
<param-value>filters.ExampleFilter.PATH_MAPPED</param-value>
</init-param>
</filter>
<filter>
<filter-name>Request Dumper Filter</filter-name>
<filter-class>filters.RequestDumperFilter</filter-class>
</filter>

<!-- Example filter to set character encoding on each request -->
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>filters.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>EUC_JP</param-value>
</init-param>
</filter>

<filter>
<filter-name>Compression Filter</filter-name>
<filter-class>compressionFilters.CompressionFilter</filter-class>

<init-param>
<param-name>compressionThreshold</param-name>
<param-value>10</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
</filter>

<!-- Define filter mappings for the defined filters -->
<filter-mapping>
<filter-name>Servlet Mapped Filter</filter-name>
<servlet-name>invoker</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>Path Mapped Filter</filter-name>
<url-pattern>/servlet/*</url-pattern>
</filter-mapping>


<!-- Example filter mapping to apply the "Set Character Encoding" filter
to *all* requests processed by this web application -->
<!--
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-->

<!--
<filter-mapping>
<filter-name>Compression Filter</filter-name>
<url-pattern>/CompressionTest</url-pattern>
</filter-mapping>
-->

<!--
<filter-mapping>
<filter-name>Request Dumper Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-->

<!-- Define example application events listeners -->
<listener>
<listener-class>listeners.ContextListener</listener-class>
</listener>
<listener>
<listener-class>listeners.SessionListener</listener-class>
</listener>

<!-- Define servlets that are included in the example application -->

<servlet>
<servlet-name>SendMailServlet</servlet-name>
<servlet-class>SendMailServlet</servlet-class>
</servlet>

<servlet>
<servlet-name>
snoop
</servlet-name>
<servlet-class>
SnoopServlet
</servlet-class>
<!--
<init-param>
<param-name>foo</param-name>
<param-value>bar</param-value>
</init-param>
-->
<run-as>
<description>Security role for anonymous access</description>
<role-name>tomcat</role-name>
</run-as>
</servlet>


<!-- Action Servlet Configuration -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>myTest.struts.MessageResources</param-value>
</init-param>
<init-param>
<param-name>mapping</param-name>
<param-value>org.apache.struts.action.RequestActionMapping</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>







<servlet>
<servlet-name>servletToJsp</servlet-name>
<servlet-class>servletToJsp</servlet-class>
</servlet>

<servlet>
<servlet-name>CompressionFilterTestServlet</servlet-name>
<servlet-class>
compressionFilters.CompressionFilterTestServlet
</servlet-class>

</servlet>
<servlet>
<servlet-name>CardValidator</servlet-name>
<servlet-class>CardValidator</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>
CompressionFilterTestServlet
</servlet-name>
<url-pattern>
/CompressionTest
</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>CardValidator</servlet-name>
<url-pattern>/CardValidator</url-pattern>
</servlet-mapping>



<servlet-mapping>
<servlet-name>SendMailServlet</servlet-name>
<url-pattern>/SendMailServlet</url-pattern>
</servlet-mapping>

<!-- Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>



<servlet-mapping>
<servlet-name>
snoop
</servlet-name>
<url-pattern>
/snoop
</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>
servletToJsp
</servlet-name>
<url-pattern>
/servletToJsp
</url-pattern>
</servlet-mapping>




<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>

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

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

<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>
http://jakarta.apache.org/tomcat/debug-taglib
</taglib-uri>
<taglib-location>
/WEB-INF/jsp/debug-taglib.tld
</taglib-location>
</taglib>

<taglib>
<taglib-uri>
http://jakarta.apache.org/tomcat/examples-taglib
</taglib-uri>
<taglib-location>
/WEB-INF/jsp/example-taglib.tld
</taglib-location>
</taglib>




<resource-ref>
<res-ref-name>mail/Session</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
</resource-ref>

<security-constraint>
<display-name>Example Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<!-- Define the context-relative URL(s) to be protected -->
<url-pattern>/jsp/security/protected/*</url-pattern>
<!-- If you list http methods, only those methods are protected -->
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<!-- Anyone with one of the listed roles may access this area -->
<role-name>tomcat</role-name>
<role-name>role1</role-name>
</auth-constraint>
</security-constraint>

<!-- Default login configuration uses form-based authentication -->
<login-config>
<auth-method>FORM</auth-method>
<realm-name>Example Form-Based Authentication Area</realm-name>
<form-login-config>
<form-login-page>/jsp/security/protected/login.jsp</form-login-page>
<form-error-page>/jsp/security/protected/error.jsp</form-error-page>
</form-login-config>
</login-config>

<!-- Environment entry examples -->
<!--env-entry>
<env-entry-description>
The maximum number of tax exemptions allowed to be set.
</env-entry-description>
<env-entry-name>maxExemptions</env-entry-name>
<env-entry-value>15</env-entry-value>
<env-entry-type>java.lang.Integer</env-entry-type>
</env-entry-->
<env-entry>
<env-entry-name>minExemptions</env-entry-name>
<env-entry-value>1</env-entry-value>
<env-entry-type>java.lang.Integer</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>foo/name1</env-entry-name>
<env-entry-value>value1</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>foo/bar/name2</env-entry-name>
<env-entry-value>true</env-entry-value>
<env-entry-type>java.lang.Boolean</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>name3</env-entry-name>
<env-entry-value>1</env-entry-value>
<env-entry-type>java.lang.Integer</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>foo/name4</env-entry-name>
<env-entry-value>10</env-entry-value>
<env-entry-type>java.lang.Integer</env-entry-type>
</env-entry>

<!-- EJB Reference -->
<ejb-ref>
<description>Example EJB Reference</description>
<ejb-ref-name>ejb/Account</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<home>com.mycompany.mypackage.AccountHome</home>
<remote>com.mycompany.mypackage.Account</remote>
</ejb-ref>

<!-- Local EJB Reference -->
<ejb-local-ref>
<description>Example Local EJB Reference</description>
<ejb-ref-name>ejb/ProcessOrder</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>com.mycompany.mypackage.ProcessOrderHome</local-home>
<local>com.mycompany.mypackage.ProcessOrder</local>
</ejb-local-ref>


</web-app>

I dont get any errors in tomcat startup console..
this is the message in tomcat console.

Jun 28, 2005 11:05:25 AM org.apache.commons.modeler.Registry loadRegistry
INFO: Loading registry information
Jun 28, 2005 11:05:25 AM org.apache.commons.modeler.Registry getRegistry
INFO: Creating new Registry instance
Jun 28, 2005 11:05:26 AM org.apache.commons.modeler.Registry getServer
INFO: Creating MBeanServer
Jun 28, 2005 11:05:27 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on port 8080
Starting service Tomcat-Standalone
Apache Tomcat/4.1.24
Jun 28, 2005 11:05:34 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on port 8080
Jun 28, 2005 11:05:34 AM org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:8009
Jun 28, 2005 11:05:34 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=31/63 config=D:\Tomcat 4.1\conf\jk2.properties
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just shooting from the hip here, but did you add the new jars to the buildpath?
 
selvi family
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes I did..
I have added struts.jar and other JAR files in to /WEB-INF/lib.
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If u have updated jar files and tlds in the correct path it wont give any problem. If still you are getting the same exception as per i know you use the taglib-uri name which u have given in the web.xml in the jsp also. taglib-location in web.xml you wont specify the relative path ,you try by specifying the absolute path of tlds. And you use the taglib-uri which u specified in web.xml in jsp. <taglib-uri>xxx </taglib-uri> is the logical name. You use that name in jsp. What ever you specified here must be use in jsps to import.
 
selvi family
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have placed my JSP directly under my application folder i.e inside /struts.
now its able to find the *.tld.
 
reply
    Bookmark Topic Watch Topic
  • New Topic