Download nhạc từ các trang nhạc lớn của Việt Nam

30 Tháng Ba 2006
@ 06:00
(Được đăng bởi: Phạm Đức Hải)

<taglib:tutorial lesson="2">

In this part of the tutorial, we will create a Tag that accepts and displays a parameter.

1 Lesson 2, Your first parameterised Tag

    In this part of the tutorial, we will create a Tag that accepts and displays a parameter. We will continue to use the setup previously defined.

    As you might have noticed in lesson 1, even a simple Tag requires us to write a number of methods that we will be using over and over again. The natural thing to do would be to make a generic Tag that we can extend throughout this tutorial. But surprise! Sun has already done so for us. In the javax.servlet.jsp.tagext package, there is a class called TagSupport that looks like in figure 1 below:


    Figure 1: The TagSupport class.

    Apart from the methods that is required by the Tag interface, the TagSupport class holds some utility methods that we can take advantage of. Amongst these are:

    • findAncestorsWithClass() will go one step further of the getParent() method and traverse all parent Tags to this one to find the closest occurrence of a certain Tag.

    • getId() and setId() gives us ready-to-go methods for setting a parameter called Id for all Tags that extends the TagSupport class. Perfect for simple single parameter type Tags.

    We will now leave the TagSupport to get on with the tutorial. If you want to learn more or get a deeper understanding about the TagSupport, read the JSP API or the JSP 1.1 Specification.

2 Creating the Hello Tag

    We will now create a Tag called 'HelloTag' that extends the TagSupport class as shown in Figure 2 below.


    Figure 2: The HelloTag extends the TagSupport class.

    1. In the '/WEB-INF/classes/com/acme/tag/' directory, create a new class called 'HelloTag.java' with the following content:


      package com.acme.tag;


      import javax.servlet.jsp.*;
      import javax.servlet.jsp.tagext.*;


      public class HelloTag extends TagSupport
      {
      private String name="";

      Listing 1: Starting of the Tag.

      As you can see in the code given above, we declare that our HelloTag will extend the TagSupport class. The variable name above will hold an optional name that will be used later in the Tag.

    2. Add the constructor:


      public HelloTag()
      {
      super();
      }

      Listing 2: The constructor.

    3. Add the following method:


      public void setName(String name)
      {
      this.name=name;
      }

      Listing 3: Adding the setName method.

      The JSP container calls the method above if a name is submitted to the Tag. How then will the JSP container know what to set? Well, well go into that below.

    4. Now add the following method:


      public int doEndTag() throws javax.servlet.jsp.JspTagException
      {
      try
      {
      pageContext.getOut().write("Hello "+name+"!");
      }
      catch(java.io.IOException e)
      {
      throw new JspTagException("IO Error: " + e.getMessage());
      }
      return EVAL_PAGE;
      }
      }

      Listing 4: Overriding the doEndTag method.

      The method above will use the PageContext to get a JspWriter class. It will then use this Writer to write a message to the encapsuling JSP page.

      As the SupportTag has implemented a doStartTag() method that returns SKIP_BODY, we do not need to implement that or any other method that we don't want to override.

    5. Compile your Tag

    By now, your HelloTag.java should look like this

3 Writing the descriptor

    With the new Tag in place, we should add a descriptor of our new Tag to the Tags descriptor we created in the first lesson.

    1. Open your 'taglib.tld' from your '/WEB-INF' directory with your favourite editor.

    2. Add the following description for your new Tag:


      <tag>
      <name>hello</name>
      <tagclass>com.acme.tag.HelloTag</tagclass>
      <bodycontent>empty</bodycontent>
      <info>A Hello Tag</info>
      <attribute>
      <name>name</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
      </attribute>
      </tag>

      Listing 5: Adding a Tag descriptor for the Tag.

    This will tell our JSP container that the new tag can accept an attribute called Name and that the Tags body should be empty. The <rtexprvalue> that is set to false will tell the Container that the name attribute will not be evaluated at runtime (i.e. can not be a dynamic value).

    Your taglib.tld should now look like this.

4 Creating a presentation

    In order to test our new Tag, we need to write a JSP page that uses it.

    1. Create a new file called 'hello.jsp' in your '/taglib-tutorial-web/' directory with the following content:


      <%@ taglib uri="mytags" prefix="mt" %>
      <HTML>
      <HEAD>
      <TITLE>Hello!</TITLE>
      </HEAD>
      <BODY BGCOLOR="#FFFFFF">
      <HR>
      <mt:hello name="foo"/>
      <HR>
      </BODY>
      </HTML>

      Listing 6: A sample JSP page.

      In the page above, we first tell the Container a reference to our Taglib descriptor. We then use the HelloTag by using its defined name ('hello') with a name attribute of "foo".

    2. Make sure that you store your file as 'hello.jsp' in your '/taglib-tutorial-web/' directory.

    By now, your 'hello.jsp' page should look like this.

5 Using your new Tag

    Its now time to test your new tag.

    1. Open the URL 'http://localhost/taglib/hello.jsp' in a normal web browser.

    Hopefully the result looks like this

    Continue with lesson 3, "Writing a BodyTag".

Copyright © 2005 IronFlare AB

Ý kiến [0] - Chuyên mục: Java

Referred by:
"java blog""code" (www.google.com.vn) [Referral]
ví dụ taglib (www.google.com.vn) [Referral]
get directory java content ubuntu (www.google.com.vn) [Referral]
TagSupport class (www.google.com.vn) [Referral]
Taglib .tag (www.google.com.vn) [Referral]
import taglib.tld (www.google.com.vn) [Referral]
taglib parameterised (www.google.com.br) [Referral]
learn to build taglib with java (www.google.com.vn) [Referral]
hello.jsp (www.google.com.vn) [Referral]
hello taglib (www.google.com.vn) [Referral]
"taglib tutorial" (www.google.com.vn) [Referral]
lời bài hát leave getout (www.google.com.vn) [Referral]
taglib in jsp with parameter (www.google.com.vn) [Referral]
taglib in jsp with parametter (www.google.com.vn) [Referral]
blog jsp (www.google.com.vn) [Referral]
jsp taglib + download (www.google.com.vn) [Referral]
how to import javax.servlet (www.google.com.vn) [Referral]
Taglib (www.google.com.vn) [Referral]
jsp: use taglib (www.google.com.vn) [Referral]
how to built a web browser with java (www.google.com.vn) [Referral]
TagSupport taglib (www.google.com.vn) [Referral]
simple taglib sample (www.google.com.vn) [Referral]
"TAG attribute" (www.google.com.vn) [Referral]
build taglib (www.google.com.vn) [Referral]
taglib 2 (www.google.ca) [Referral]
taglib jsp (www.google.com.vn) [Referral]
taglib + jsp (www.google.com.vn) [Referral]
tutorial taglib java (www.google.com.vn) [Referral]
ant build taglib (www.google.lt) [Referral]
"taglib java" (www.google.com.vn) [Referral]
taglib (www.google.com.vn) [Referral]
create taglib (www.google.com.vn) [Referral]
taglib (www.google.com.vn) [Referral]
taglib trong jsp (www.google.com.vn) [Referral]
"taglib"+"TagSupport"+"download" (www.google.com) [Referral]
tag trong JSP (www.google.com.vn) [Referral]
how import taglib (www.google.com.vn) [Referral]
SupportTag source code (www.google.com) [Referral]
extend jsp taglib (www.google.com.vn) [Referral]
first taglib (www.google.com.vn) [Referral]
taglib,jsp (www.google.com.vn) [Referral]
first <taglib> (www.google.com) [Referral]
add taglib jsp (www.google.com.vn) [Referral]
su dung taglib,JSP (www.google.com.vn) [Referral]
use taglib, JSP (www.google.com.vn) [Referral]
ajax taglib (www.google.com.vn) [Referral]
su dung taglib ,JSP (www.google.com.vn) [Referral]
ajax taglib (www.google.com.vn) [Referral]
TagSupport (www.google.com.vn) [Referral]
EMPTY TAG jsp (www.google.com.vn) [Referral]
taglib (www.google.com.vn) [Referral]
vi du ve taglib (www.google.com.vn) [Referral]
blog buid (www.google.com.vn) [Referral]
build botnet with java (www.google.com.vn) [Referral]
taglib demo + source code (www.google.com.vn) [Referral]
taglib (www.google.com.vn) [Referral]
hold me (www.google.com.vn) [Referral]
the package implements the tag interface java.servelet. (www.google.com.vn) [Referral]
tại taglib trong jsp (www.google.com.vn) [Referral]
FirstTaglib example with jsp (www.google.com) [Referral]
how to create taglib (www.google.com.vn) [Referral]
taglib (www.google.com.vn) [Referral]
taglib (www.google.com.vn) [Referral]
taglib jsp tutorial (www.google.com.vn) [Referral]
how to creat taglib + java (www.google.com.vn) [Referral]
"ví dụ taglib" (www.google.com.vn) [Referral]
java taglib tutorial (www.google.com.vn) [Referral]
build taglib include image (www.google.com.vn) [Referral]
import taglib (www.google.com.vn) [Referral]
taglib sample (www.google.com.vn) [Referral]
built taglib (www.google.com.vn) [Referral]
head + taglib (www.google.com.vn) [Referral]
package + "taglib" (www.google.com.vn) [Referral]
taglib (www.google.com.vn) [Referral]
first taglib tutorial (www.google.com.au) [Referral]
cach dung taglib trong jsp (www.google.com.vn) [Referral]
java taglib reference (www.google.com.vn) [Referral]
ajax viet guru (www.google.com) [Referral]
"write simple taglib" (www.google.com.vn) [Referral]
java taglibs tutorial (www.google.fr) [Referral]
step by step create taglib in Java (www.google.com.vn) [Referral]
taglib write (www.google.com.vn) [Referral]
taglib tagsupport tutorial (hk.search.yahoo.com) [Referral]
+taglib +tagsupport +example (www.google.es) [Referral]
taglib can ban (www.google.com.vn) [Referral]
taglib sample source (www.google.com.vn) [Referral]
why taglib jsp (www.google.com.vn) [Referral]
ví dụ về taglib (www.google.com.vn) [Referral]
create taglibs (www.google.ch) [Referral]
vi du taglib (www.google.com.vn) [Referral]
jsp ajax taglib demo (www.google.com) [Referral]
taglib (www.google.co.uk) [Referral]
make taglib parameter java (www.google.com.br) [Referral]
simple taglib example (www.google.com) [Referral]
importing taglib sample (www.google.com) [Referral]
writing a taglib class (www.google.co.in) [Referral]
vi thuy linh (translate.google.com.vn) [Referral]
taglib tagsupport (www.google.com.br) [Referral]
java taglib 2.0 tutorial (www.google.com) [Referral]
simple taglib example (www.google.co.in) [Referral]
tutorial taglib 2.0 (www.google.com.br) [Referral]
taglib extend (www.google.es) [Referral]
tutorial on how to create own taglibs (www.google.co.in) [Referral]
tutorial how to make taglib get parameters (www.google.com) [Referral]
cach add taglib trong jsp (www.google.com.vn) [Referral]
taglib trong jsp (www.google.com.vn) [Referral]
jsp taglib Tagsupport (www.google.com) [Referral]
taglib jsp 2 tutorial (www.google.com) [Referral]
create your own taglib (www.google.de) [Referral]
"jsp 2" taglib tutorial (www.google.com) [Referral]
java create taglib (hk.search.yahoo.com) [Referral]
how to make taglib (www.google.it) [Referral]
ant build taglib (www.google.com) [Referral]
java taglib tutorial (www.google.ca) [Referral]
taglib tagsupport class (www.google.nl) [Referral]
extends TagSupport + order of setting parameters (www.google.pl) [Referral]
taglib c:set var "own taglib" (www.google.de) [Referral]
Compile taglib (www.google.com) [Referral]
build taglib (www.google.com.br) [Referral]
"taglib 2" (www.google.com) [Referral]
create taglib parameterised Tag (www.google.fr) [Referral]
how to write a taglib with parameters (www.google.co.uk) [Referral]
taglib sample (www.google.fr) [Referral]
cách add taglib trong java (www.google.com.vn) [Referral]
taglib get directory listing (www.google.com) [Referral]
java taglib tutorial (www.google.co.uk) [Referral]
java jsp TagSupport tutorial (www.google.co.uk) [Referral]
jsp taglib tutorial (www.google.de) [Referral]
java taglib tutorial 2.0 (www.google.se) [Referral]
java create taglib (www.google.com) [Referral]
portaloffice.com.vn (www.google.com) [Referral]
taglib tag parameter (www.google.nl) [Referral]
howto create taglib (www.google.es) [Referral]
Java taglib create (www.google.de) [Referral]
how to import javax.servlet.* (www.google.com) [Referral]
make jsp 2.0 taglib (www.google.be) [Referral]
send a value to a extends TagSupport class (www.google.pt) [Referral]
taglib tutorial example (www.google.co.in) [Referral]
taglib parameter tutorial (www.google.de) [Referral]
howto java tagsupport (www.google.se) [Referral]
jsp taglib example (www.google.co.in) [Referral]
java taglibs tagsupport (www.google.be) [Referral]
make your own taglib (www.google.com) [Referral]
java; taglib; tutorial (www.google.ca) [Referral]
taglib 2.0 (www.google.ru) [Referral]
tagsupport example (www.google.es) [Referral]
java make taglib (www.google.it) [Referral]
su dung taglib (www.bing.com) [Referral]
taglib tutorial (www.google.com) [Referral]
how to write a taglib example (www.google.com) [Referral]
taglib tutorial (www.google.com) [Referral]
own taglib (www.google.com) [Referral]
java taglib examples tagsupport (www.google.es) [Referral]
taglib 2 (www.google.fr) [Referral]
taglib tutorial (www.google.com) [Referral]
how to create own taglibs (www.google.co.in) [Referral]
su dung bing (www.bing.com) [Referral]
compile taglib (www.google.si) [Referral]
Java taglib for writing image (www.google.com) [Referral]
how to inport javax.servlet.* (www.google.com) [Referral]
ajax taglibs jsp (www.google.com.au) [Referral]
build taglib for jsp in java TagSupport (www.google.com) [Referral]
writing java taglib (www.google.com) [Referral]
write own taglib tagsupport (www.google.com) [Referral]
"package implements the tag interface' (www.google.com.vn) [Referral]
taglib sample (www.google.com) [Referral]
java taglib tutorial (www.google.com) [Referral]
create a first tag lib (www.google.com) [Referral]
hello taglib examples (www.google.co.in) [Referral]
taglib sample (www.google.co.in) [Referral]
Writing JSP Taglib TagSupport (www.google.com) [Referral]
guru tutorial for taglib\ (www.google.com) [Referral]
create taglibs (www.google.com) [Referral]
viết taglib trong jsp (www.google.com.vn) [Referral]
download taglib tld (www.google.com.vn) [Referral]
taglib descriptor directory (www.google.com.vn) [Referral]
using taglib in jsp (www.google.com.vn) [Referral]
hello taglib (www.google.com.vn) [Referral]
su dung taglib bang class (www.google.com.vn) [Referral]
3 cach khai bao taglib (www.google.com.vn) [Referral]
taglib example (www.google.com.vn) [Referral]
taglib can not resolve to a type (www.google.com.vn) [Referral]
JSP tag lib .tag (www.google.com.vn) [Referral]
download package jsp.tagext (www.google.com.vn) [Referral]
how to write jsp tag lib (www.google.com.vn) [Referral]
taglib (www.google.com.vn) [Referral]
ajax taglib tld (www.google.com.vn) [Referral]
include taglib auto import (www.google.com.vn) [Referral]
loi taglib sql (www.google.com.vn) [Referral]
code taglib (www.google.com.vn) [Referral]
taglib demo (www.google.com.vn) [Referral]
rtexprvalue tag lib descriptor (www.google.com.vn) [Referral]
tag lib trong jsp (www.google.com.vn) [Referral]
send parameter via taglib (www.google.com.vn) [Referral]
su dung taglib jsp (www.google.com.vn) [Referral]
cannot import package in taglib (www.google.com.vn) [Referral]
java taglib tutorial (www.google.co.uk) [Referral]
servlet set attributes of taglib (www.google.com.vn) [Referral]
taglig java (www.google.com.vn) [Referral]
cách dùng @taglib (www.google.com.vn) [Referral]
how to check String empty on taglib jsp (www.google.com.vn) [Referral]
taglib jsp (www.google.com.vn) [Referral]
"java taglib" (search.babylon.com) [Referral]
add taglib trong jsp (www.google.com.vn) [Referral]
set taglib in servlet (www.google.com.vn) [Referral]
vietguru.com (www.google.com.vn) [Referral]
write taglib jsp (www.google.com.vn) [Referral]
taglib step by step (www.google.com.vn) [Referral]
java taglib tutorial (www.google.com.vn) [Referral]
taglib c (www.google.com.vn) [Referral]
JSP cach viet 1 taglib (www.google.com.vn) [Referral]
java pass parameter to taglib (www.google.com.vn) [Referral]
java taglib constructor (www.google.com.vn) [Referral]
c if taglib (www.google.com.vn) [Referral]
servlet create taglib (www.google.com.vn) [Referral]
cach su dung taglib trong JSP (www.google.com.vn) [Referral]
build jsp taglib (www.google.com.vn) [Referral]
sample jsp in java (www.google.com.vn) [Referral]
http://yandex.ru/yandsearch?text=java+example+taglib&yasoft=... [Referral]
chiara poggi (play-mp3.com) [Referral]
blog build viet (www.google.com.vn) [Referral]
java taglib tutorial (www.google.com) [Referral]
taglib (www.google.com.vn) [Referral]
create tag lib sample (www.google.com.vn) [Referral]
the import javax.servlet cannot be resolved (www.google.com.vn) [Referral]
The import javax.servlet cannot be resolved (www.google.com.vn) [Referral]
java taglib tutorial (www.google.co.uk) [Referral]
taglib jsp (www.google.com.vn) [Referral]
rtexprvalue tag (www.google.com.vn) [Referral]
how to use taglib <c:if (www.google.com.vn) [Referral]
'taglib2.0.tld' (www.google.com) [Referral]
cach su dung tablib trong jsp (www.google.com.vn) [Referral]
building a JSP simple tag (www.google.com.vn) [Referral]
http://aptech.ac.vn:8080/course/view.php?id=543 [Referral]
taglib examples mp3 -sharp (www.google.com) [Referral]
tag lib trong java (www.google.com.vn) [Referral]
php create taglib (www.google.com.vn) [Referral]
tag lib (www.google.com.vn) [Referral]
dynamic attribute in taglib (www.google.com.vn) [Referral]
taglib java (www.google.com.vn) [Referral]
ajax taglib turtorial (www.google.com.vn) [Referral]
chech empty taglib (www.google.com.vn) [Referral]
creating taglib (www.google.com.sg) [Referral]
compile taglib example (www.google.com) [Referral]
taglib turtorial (www.google.com.tw) [Referral]
how to build tag lib (www.google.com.vn) [Referral]
google translator taglib in jsp example (www.google.co.in) [Referral]
taglib parameter (www.google.gr) [Referral]
<title>ASPXspy</title> (www.google.it) [Referral]
java taglib tutorial (www.google.co.uk) [Referral]
create taglib play (www.google.com) [Referral]
"taglib c" ubuntu (www.google.com) [Referral]
java taglib example (www.google.fi) [Referral]
tutorial java create taglib (www.google.com) [Referral]
should be an empty taglib (www.google.com.ar) [Referral]
taglib 2.0 (www.google.ch) [Referral]
download taglib.tld (www.google.ca) [Referral]
how to create our own c taglib (www.google.co.in) [Referral]
taglib hello (www.google.com.br) [Referral]
java taglib tutorial (www.google.com) [Referral]
create taglibs (www.google.fr) [Referral]
why taglib (www.google.ca) [Referral]
taglib jsp compile (www.google.se) [Referral]
create taglib (www.google.ro) [Referral]
tutorial taglib 2 (www.google.fr) [Referral]
taglib c tutorial (www.google.com) [Referral]
taglib 2 (www.google.fr) [Referral]
make taglib with php code 5 (www.google.com.br) [Referral]
taglib tutorial (www.google.com) [Referral]
taglib parameter (www.google.com.br) [Referral]
taglib 2.0 (www.google.de) [Referral]
java taglib tutorials (www.google.com.ph) [Referral]
taglib 2.0 tutorial (www.google.se) [Referral]
taglib 2.0 (www.google.sk) [Referral]
taglib parameter (www.google.es) [Referral]
hello java taglib (www.google.ch) [Referral]
java taglib example (www.google.com) [Referral]
<taglib> parameter (www.google.com.br) [Referral]
java taglib tutorial (www.google.co.nz) [Referral]
java howto taglib (www.google.se) [Referral]
creating taglibs (www.google.co.in) [Referral]
taglib tutorial (www.google.co.il) [Referral]
taglib parameter (www.google.com) [Referral]
how to import javax.servlet.*; (www.google.co.in) [Referral]
http://www.google.de/ [Referral]