Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom tag clarification  RSS feed

 
hob hartman
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pardon if this is elementary but I would appreciate some help getting the correct file structure for the custom tag development. Right now my JSP setup has:
/JSP root web app (putting my jsp's in here)
/JSP/WEB-INF/classes (putting my beans and servlets in here)
I tried the Sun tutorial and the Jakarta tutorial and also looked at the examples included with Tomcat under webapps but have not succeeded correctly placing the taglib, web.xml, and the tag handler class file. Currently have the my calling jsp in /JSP, web.xml and the taglib in /WEB-INF and my tag handler class in /classes.
Any guidance or referal to clear documentation?
Thanks,
hob
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It isn't an elementary question. Lot of people get struck with this.....
General guidelines:
1. When using Beans and Custom Tags, put them in packages. When you don't use packages, you must put the class files in the WEB-INF/classes folder. However, when accessing them in your JSP, the app server class loader (atleast for Tomcat server) looks for the class files in the same package that your generated Servlet code (for the JSP) is located. Obviously, your Bean/Tag class is NOT in that package. So errors follow. To aviod these, put your Beans/Tags in packages.
2. In Tomcat, there seems to be a bug (4.0.1 version) which doesn't load your Tag libraries from the TLD's available in your WEB-INF/ folder. So you are forced to use the < taglib > element of your webapp element in your web.xml (DD) to load the required tag library TLD files.
3. The DD, web.xml, file must be in WEB-INF dir. The Bean/Tag classes must be in the corresponding dir hierarchy under WEB-INF/classes/<packages go here>/.class files. If you have them in jars, place them in WEB-INF/lib dir.
regds.
- satya
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!