Win a copy of Securing DevOps this week in the Security forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom tags Problem  RSS feed

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
I am having an error with tomcat which says
=>
org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 11 in the jsp file: /hi.jsp
test2 cannot be resolved to a type
8:
9: <%@ taglib prefix="my" uri="dog" %>
10:
11: <my:dimple/>
12:
13: </body>
14:
---------------------------------------------------------------------------
My TLD file (simple.tld) is(placed in /web-inf dir)

<?xml version="1.0" encoding="UTF-8" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">

<tlib-version>1.2</tlib-version>
<short-name>java</short-name>
<uri>dog</uri>
<tag>
<name>dimple</name>
<tag-class>test2</tag-class>
<body-content>scriptless</body-content>
</tag>
</taglib>
-------------------------------------------------------------------------
My class file (in web-inf/classes dir)


--------------------------------------------------------------------------
My jsp file (root)

<html><body>

<%@ taglib prefix="my" uri="dog" %>

<my:dimple>
${alpha}
</my:dimple>

</body></html>

I cant get this thing working . Please help.


[BPSouther: Added code tags]
[ August 31, 2007: Message edited by: Ben Souther ]
 
Author and ninkuma
Marshal
Posts: 66487
160
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly, you should be following convetional naming standards. Classes should being with a capital letter. As in Test2.

Secondly, place your class in a package other than the default. See the JSP FAQ for more information on this.
 
saravana.T kumar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, it worked.

And why should it be kept inside packages and not in the classes folder

2.is this above thing appplicable to custom tags or all jsp files which includes classes
 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
saravana, did you read the JSP FAQ concerning this subject?
 
Anything worth doing well is worth doing poorly first. Just look at this tiny ad:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!