Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to run jsp page has custom tags

 
Tom Barns
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
how do we can run a jsp page with a custome tag.
I'm sure we need to creat jar file that include the class and
web-inf to include the decriptor file ..
is someone has an example oe steps how to do just small and very simple example to run a jsp page with a very simple custom tag,please let me know.
thanks all,i will appreciate that.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13077
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Orion people have a very nice taglib tutorial on their site at: http://www.orionserver.com
Also at that site, some pretty interesting benchmarks!
Bill
(or you could buy my book - Java Developer's Guide to Servlets and JSP - it has a chapter on custom tag libraries)
 
Preethi Chaloori
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!Tom,
Following are the main things you need to write custom jsp tags:
1. Write a Tag implementation class. Your class must either extend TagSupport or BodyTagSupport classes( Which in turn implement Tag interface). Give your imple in appropriate method
2. Create a TLD file(tag Library discriptor file) to define your custom tags. Shortname is generally the prefix that your planning to use. The <tag><name> is generally the suffix you are planning to use.
<tagclass = takes the absolute path of the class file>
eg: <preethi:customtag>
3. Create a jsp file and include the following line
<%@ taglib uri="name of the tld file" prefix="shortname" %>

use the custom tags whereever you want the desired behavior
Now once everything is in place, the following steps are needed if you are using Tomcat:
1. create a web.xml file or copy the one they have already provided in the examples and follow the setup. You need to give your tld file name here.
2. Copy the manifest file from the examples
3. create a war file. It will create in your current directory. Cut and paste it into WebApps directory.

4. Open the server.xml file and to the end add the path. You will be using this to test your jsp
Well, make sure the server is running and the type in the location of the jsp page and you should see the results
If this dosen't help you go to
www.javasoft.com and type in JSPTag Library tutorials in the search and you will be all set.
The key point is that all the files should be in the right directory structure.
Preethi :-))
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic