Using EL How to Write a Customize tag

I want to write a tag wich takes input and output as it is.Like when i pass an primitive types then it directly pass no transfer as we are puting "" literial to the values and pass it.
For Example:
<fun:add i1=10 i2=20 />
check my code as i write tld ,and classes
------ function.jsp ------
<%@ taglib uri="http://jakarta.apache.org/explang/funtion-taglib"
prefix="fun" %>
<%=<fun:add i1="10" i2="20" /> %>
----------function.tld-------------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
     "http://java.sun.com/j2ee/dtd/web-jsptaglibrary_2_0.dtd">
<taglib>
<tlib-version>1.2</tlib-version>
<jsp-version>2</jsp-version>
<short-name>fun</short-name>
<tag>
<name>add</name>
<tag-class>exp.MyClass</tag-class>
<body-content>TAGDEPENDENT</body-content>
<resolver-class>exp.MyVarRes</resolver-class>
<expression-class>exp.MyExp</expression-class>
<attribute>
<name>i1</name>
<required>true</required>
</attribute>
<attribute>
<name>i2</name>
<required>true</required>
</attribute>
</tag>
</taglib>
---------evalutor&other classes-------
------MyClass.java-------
package explang;
public class MyClass{
public int add(int x,int y){
return(x+y);
--------MyExp----------------
package explang;
import javax.servlet.jsp.el.*;
public class MyExp extends Expression{
public Object evaluate(VariableResolver vr)throws ELException{
     try{
          System.out.println("Execute evalute on MyExp");
return Class.forName("java.lang.Integer.class");
     }catch(Exception e){ return null;}
------------MyExpEval----------------------
package explang;
import javax.servlet.jsp.el.*;
public class MyExpEval extends ExpressionEvaluator{
private int i1,i2;
public void setI1(Integer i1){
this.i1=i1.intValue();
public void setI2(Integer i2){
this.i2=i2.intValue();
public java.lang.Object evaluate(java.lang.String name,java.lang.Class cls,javax.servlet.jsp.el.VariableResolver vr,javax.servlet.jsp.el.FunctionMapper fm)
throws ELException{
     MyClass mc=new MyClass();
try{
mc=(MyClass)cls.newInstance();
}catch(Exception e){ }
int res=mc.add(i1,i2);
return new Integer(res);
public javax.servlet.jsp.el.Expression parseExpression(java.lang.String name,java.lang.Class cls,javax.servlet.jsp.el.FunctionMapper fm)
throws ELException{
return null;
------------MyVarRes------
package explang;
import javax.servlet.jsp.el.*;
import javax.servlet.jsp.PageContext;
public class MyVarRes implements VariableResolver{
     private PageContext mCtx;
     public MyVarRes(PageContext ctx){
          System.out.println("Intialize the PageContext");
          this.mCtx=ctx;
     public Object resolveVariable(String pName )throws ELException{
          if("pageContext".equals(pName))
return mCtx;
else
return mCtx.findAttribute(pName);
public Object resolveVariable(String name,Object gtype)throws ELException{
if(gtype instanceof java.lang.Long)
return (java.lang.Integer)gtype;
return null;
Is there any solution plz guide me,i have somewhere stuck in the middle bcz of this?

I want to write a tag wich takes input and output as
it is.Like when i pass an primitive types then it
directly pass no transfer as we are puting ""
literial to the values and pass it.
For Example:
<fun:add i1=10 i2=20 /> Can't do that, and even if you could, you shouldn't.
1: Correct XHTML syntax requires the quotes, and custom tags were designed to fit into XHTML syntax.
2: What would you possibly gain? doing <fun:add i1="10" i2="20" /> will translate the values to the appropriate data type for you - if you declare your set-method to have a Long prameter, then these values will be translated to Longs... Same for primitives...
check my code as i write tld ,and classes
------ function.jsp ------
<%@ taglib
uri="http://jakarta.apache.org/explang/funtion-taglib"
prefix="fun" %>
<%=<fun:add i1="10" i2="20" /> %>What are you trying to do here? You can't put a custom tag inside a scriptlet/expression like that. You would either use custom tags OR scriptlets, not both. After all, what goes between <% ... %> tags (and <%= ... %>) needs to be Java code. And <fun:add i1="10" i2="20"/> is not java code.

Similar Messages

  • Using EL How to write a custom tag?

    I want to write a tag wich takes input and output as it is.Like when i pass an primitive types then it directly pass no transfer as we are puting "" literial to the values and pass it.
    For Example:
    <fun:add i1=10 i2=20 />
    check my code as i write tld ,and classes
    ------ function.jsp ------
    <%@ taglib uri="http://jakarta.apache.org/explang/funtion-taglib"
    prefix="fun" %>
    <%=<fun:add i1=10 i2=20 /> %>
    ----------function.tld-------------
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE taglib
    PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
    "http://java.sun.com/j2ee/dtd/web-jsptaglibrary_2_0.dtd">
    <taglib>
    <tlib-version>1.2</tlib-version>
    <jsp-version>2</jsp-version>
    <short-name>fun</short-name>
    <tag>
    <name>add</name>
    <tag-class>exp.MyClass</tag-class>
    <body-content>TAGDEPENDENT</body-content>
    <resolver-class>exp.MyVarRes</resolver-class>
    <expression-class>exp.MyExp</expression-class>
    <attribute>
    <name>i1</name>
    <required>true</required>
    </attribute>
    <attribute>
    <name>i2</name>
    <required>true</required>
    </attribute>
    </tag>
    </taglib>
    ---------evalutor&other classes-------
    ------MyClass.java-------
    package explang;
    public class MyClass{
    public int add(int x,int y){
    return(x+y);
    --------MyExp----------------
    package explang;
    import javax.servlet.jsp.el.*;
    public class MyExp extends Expression{
    public Object evaluate(VariableResolver vr)throws ELException{
    try{
    System.out.println("Execute evalute on MyExp");
    return Class.forName("java.lang.Integer.class");
    }catch(Exception e){ return null;}
    ------------MyExpEval----------------------
    package explang;
    import javax.servlet.jsp.el.*;
    public class MyExpEval extends ExpressionEvaluator{
    private int i1,i2;
    public void setI1(Integer i1){
    this.i1=i1.intValue();
    public void setI2(Integer i2){
    this.i2=i2.intValue();
    public java.lang.Object evaluate(java.lang.String name,java.lang.Class cls,javax.servlet.jsp.el.VariableResolver vr,javax.servlet.jsp.el.FunctionMapper fm)
    throws ELException{
    MyClass mc=new MyClass();
    try{
    mc=(MyClass)cls.newInstance();
    }catch(Exception e){ }
    int res=mc.add(i1,i2);
    return new Integer(res);
    public javax.servlet.jsp.el.Expression parseExpression(java.lang.String name,java.lang.Class cls,javax.servlet.jsp.el.FunctionMapper fm)
    throws ELException{
    return null;
    ------------MyVarRes------
    package explang;
    import javax.servlet.jsp.el.*;
    import javax.servlet.jsp.PageContext;
    public class MyVarRes implements VariableResolver{
    private PageContext mCtx;
    public MyVarRes(PageContext ctx){
    System.out.println("Intialize the PageContext");
    this.mCtx=ctx;
    public Object resolveVariable(String pName )throws ELException{
    if("pageContext".equals(pName))
    return mCtx;
    else
    return mCtx.findAttribute(pName);
    public Object resolveVariable(String name,Object gtype)throws ELException{
    if(gtype instanceof java.lang.Long)
    return (java.lang.Integer)gtype;
    return null;
    Is there any solution plz guide me,i have somewhere stuck in the middle bcz of this?

    I want to write a tag wich takes input and output as
    it is.Like when i pass an primitive types then it
    directly pass no transfer as we are puting ""
    literial to the values and pass it.
    For Example:
    <fun:add i1=10 i2=20 /> Can't do that, and even if you could, you shouldn't.
    1: Correct XHTML syntax requires the quotes, and custom tags were designed to fit into XHTML syntax.
    2: What would you possibly gain? doing <fun:add i1="10" i2="20" /> will translate the values to the appropriate data type for you - if you declare your set-method to have a Long prameter, then these values will be translated to Longs... Same for primitives...
    check my code as i write tld ,and classes
    ------ function.jsp ------
    <%@ taglib
    uri="http://jakarta.apache.org/explang/funtion-taglib"
    prefix="fun" %>
    <%=<fun:add i1="10" i2="20" /> %>What are you trying to do here? You can't put a custom tag inside a scriptlet/expression like that. You would either use custom tags OR scriptlets, not both. After all, what goes between <% ... %> tags (and <%= ... %>) needs to be Java code. And <fun:add i1="10" i2="20"/> is not java code.

  • Which planning function i have to use and how to write this planning fucnti

    Hi Bi Guru's,
    I have rolled out  BW SEM-BPS Planning Layout's for the Annual Budget in my organistaion.
    There are two levels of layout given for the each sales person.
    1)  Sales quantity to be entered Material and  country wise for all 12 months ( April 2009 to March 2010)
    2)  Rate per unit and to entered in second sheet, Material and country wise for the total qty entered in the first layout.
    Now i need to calculate the sales vlaue for each period and for the each material.
    Which planning function i have to use and how to write this planning fucntion.
    Please suggest me some solution ASAP.
    Thanks in Advance,
    Nilesh

    Hi Deepti,
    Sorry to trouble you...
    I require your help for the following scenario for caluclating Sales Value.
    I have Plan data in the following format.
    Country   Material    Customer    Currency    Fiscyear    Fiscper           Qty         Rate        Sales Value
    AZ          M0001      CU001          #             2009          001.2009        100.00                        
    AZ          M0001      CU002          #             2009          001.2009        200.00                        
    BZ          M0001      CU003          #             2009          001.2009        300.00
    BZ          M0001      CU003          #             2009          002.2009        400.00
    BZ          M0002      CU003          #             2009          002.2009        300.00
    AZ          M0001       #               USD          2009             #                                 10.00
    BZ          M0001       #               USD          2009             #                                 15.50
    BZ          M0002       #               USD          2009             #                                 20.00
    In the Above data the Rate lines are entered in the Second Layout, Where the user enters on the Country Material Level with 2009 value for FISCYEAR.
    I am facing problem with this type of data. 
    I want to store the sales value for each Material Qty.
    Please suggest some solution.
    Re
    Nilesh

  • How do you delete a tag you no longer use in photoshop elements 12

    I have a few tags I no longer use. How do you delete a tag in Photoshop Elements 12

    Welcome to the forum.
    As Trevor points out, you need the Photoshop Elements Forum. I will Move your post to that very helpful and active forum. Your link, and any e-mail subscriptions will follow.
    Good luck,
    Hunt
    [Moved to Photoshop Elements Forum]

  • How to write this java code in jsp using jstl  tags?

    Can anybody help me on this?
    I dont know how to check the containsKey using jstl tags?
    <%
         LinkedHashMap yearMap     =     (LinkedHashMap)request.getAttribute("yearMap");
         TreeSet nocSet               =     (TreeSet)request.getAttribute("nocSet");
         Iterator     yearMapIt     =     yearMap.keySet().iterator();
         while(yearMapIt.hasNext())
              int yearValue               =     (Integer)yearMapIt.next();
    %>
    <tr>
              <td><%=yearValue%></td>
    <%
              LinkedHashMap monthMap     =     (LinkedHashMap)yearMap.get(yearValue);
              Iterator     nocSetIt     =     nocSet.iterator();
              while(nocSetIt.hasNext())
                   String nCase=(String)nocSetIt.next();
                   if(monthMap.containsKey(nCase))
                        String count     =     (String)monthMap.get(nCase);
    %>
                        <td> <%= count %> </td>
    <%            }
                   else
    %>          
                        <td> 0 </td>     
    <%          
    %>
    </tr>
    <% } %>Edited by: avn_venki on Feb 18, 2008 11:54 PM

    <c:forEach var="yearMap" items="${requestScope.yearMap}">
         <th> <c:out value="${yearMap.key}"/> </th>
    <bean:define id="monthMap" value="${yearMap.value}"/>
    <c:forEach var="nocSet" items="${nocSet}">
    then how to write containsKey using tags??

  • I am running 10.6.8 and using iweb for my web site. After several SEO analysis they all indicate I need H1-6 header tags. After looking at the source code I see there are none in iweb. Is it necessary to add? If so, how do I add H Tags to iweb.

    I am running 10.6.8 and using iweb for my web site. After several SEO analysis they all indicate I need H1-6 header tags. After looking at the source code I see there are none in iweb. Are they necessary to add?  Why would one add these tags and how do I add H Tags to iweb? And are there examples to look at? I am slowly learning about simple web design and assumed that iweb was stand alone without having to write code. Is this one of the reasons iweb is no longer supported? Thanks for looking at this!

    A simple text page like this:
    Heading
        sub heading
              text paragraph ....
    Is traditionally represented by html tags like:
    <h1>Heading</h1>
         <h2>sub heading</h2>
              <p>text paragraph ... </p>
    I would guess that the use of h1-h6 tags helps search engines to understand the structure of a page as the tags imply a certain structure.
    This can be compared to more generic tags like <div> that could represent any kind of content - and may be what iWeb uses (you'll have to check yourself).
    I would generally recommend that you use some kind of up to date blog/site building tool, perhaps Wordpress or Squarespace (I haven't used either one myself) that support current web technologies - this should reduce your SEO issues and make it easier to properly support mobile/tablet users.

  • I cannot get to or use my home pc for a while and am staying with a friend for the foreseeable and am using their pc to write this. How do I access my itunes account on their pc. Thanks Karen

    I cannot get to or use my home pc for some time and am staying at a firends and using their pc to write this. I need to access my itunes account and music on their pc. How do I do this. Thanks

    An easy route would be to use the iTunes Match service such that all your Songs are available anywhere over the internet via iCloud.  Once complete you can create an account on your friends PC, download iTunes and sign-in to the iTunes Store with your Apple Id, start iTunes Match and it will provide access to all your Songs.
    Not quite so good, is simply to follow the steps on your friends PC as above, however, instead of iTunes Match simply access the 'purchased' songs area from the iTunes Store home page that will give you access to all your purchases without iTunes Match.
    IMPORTANT:  Apple only like to see a single Apple Id associated with one device - so if your friend already has an active Apple Id account on the PC, it would be wise to use an alternate machine.  Apple has a 90 day lock out associated with switching Apple Ids on a common device.

  • How to write a procedure to load the data into a table using xml file as input to the procedure?

    Hi,
    Iam new to the xml,
    can u please anyone help me how to write procedure to load the data into a table using xml as input parameter to a procedure and xml file is as shown below which is input to me.
    <?xml version="1.0"?>
    <DiseaseCodes>
    <Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
    <Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
    <Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
    </DiseaseCodes>.
    Regards,
    vikram.

    here is the your XML parse in 11g :
    select *
      from xmltable('//Entity' passing xmltype
    '<?xml version="1.0"?>
    <DiseaseCodes>
    <Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
    <Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
    <Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
    </DiseaseCodes>
    ') columns
      "dcode" varchar2(4000) path '/Entity/dcode',
      "ddesc" varchar2(4000) path '/Entity/ddesc',
      "reauthflag" varchar2(4000) path '/Entity/reauthflag'
    dcode                                                                            ddesc                                                                            reauthflag
    0                                                                                (I87)Other disorders of veins - postphlebitic syndrome                           0
    0                                                                                (J04)Acute laryngitis and tracheitis                                             0
    0                                                                                (J17*)Pneumonia in other diseases - whooping cough                               0
    SQL>
    Using this parser you can create procedure as
    SQL> create or replace procedure myXMLParse(x clob) as
      2  begin
      3    insert into MyXmlTable
      4      select *
      5        from xmltable('//Entity' passing xmltype(x) columns "dcode"
      6                      varchar2(4000) path '/Entity/dcode',
      7                      "ddesc" varchar2(4000) path '/Entity/ddesc',
      8                      "reauthflag" varchar2(4000) path '/Entity/reauthflag');
      9    commit;
    10  end;
    11 
    12  /
    Procedure created
    SQL>
    SQL>
    SQL> exec myXMLParse('<?xml version="1.0"?><DiseaseCodes><Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity><Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity><Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity></DiseaseCodes>');
    PL/SQL procedure successfully completed
    SQL> select * from MYXMLTABLE;
    dcode                                                                            ddesc                                                                            reauthflag
    0                                                                                (I87)Other disorders of veins - postphlebitic syndrome                           0
    0                                                                                (J04)Acute laryngitis and tracheitis                                             0
    0                                                                                (J17*)Pneumonia in other diseases - whooping cough                               0
    SQL>
    SQL>
    Ramin Hashimzade

  • How to write special characters in PDF using iText

    How to write special characters encoded with UTF-8 in PDF using iText.
    Regards,
    Pandharinath.

    I don't know what your problem is but that's almost certainly the wrong question to ask about it. Java (including iText) uses only Unicode characters. (You may consider some of them to be "special" if you like but Unicode doesn't.) And when it does that, they aren't encoded in UTF-8 or any other encoding.
    So can you describe your problem? That question doesn't make sense.

  • How to write a java function for use in where clause in SQL statement

    Hi,
    Does anyone know a good tutorial on how to write and include a Java class/function into Oracle.
    I'd like to write mathematical function to use in my queries, but the resources available in PL/SQL are very limited.
    Many thanx

    Pim,
    I see you got an answer in the PL/SQL forum.
    But in case you haven't seen it, perhaps this Web page will help:
    http://www.oracle.com/technology/tech/java/jsp/index.html
    Good Luck,
    Avi.

  • How to get the customize url of an portlet using PLSQL

    How to get the customize url of an portlet using PLSQL.

    Are you trying to call the portlet Customization form directly from the browser?

  • I'm trying to update iOS 7 and it says I need 3.4 GB of storage to update.. I currently have on my storage 797 MB and 12,6 GB used. How much storage should it write for me to be able to update?

    I'm trying to update iOS 7 and it says I need 3.4 GB of storage to update.. I currently have on my storage 797 MB and 12,6 GB used. How much storage should it write for me to be able to update?

    If your ipad has only 797 MB free and it tells you that you need 3.4 GB to update, then you need to begin deleing files, whatever it takes to free up space.
    Consider...
    Delete apps you don't use.
    Delete videos you don't want (these take up a lot of space).
    Do you have a lot of emails stored on the device?
    Are there apps that store data files, like a PDF reader?  If there are a lot of these, you need to delete some.
    The bottom line is that you need to remove data and/or apps on your device to make more storage available.
    But for videos and photos, always sync them to a computer first to archive them.

  • How to write a log using abap mapping

    Hi all.
    in PI 7.1 environment I need to use abap mapping and I wish to write some XML data into a table that I created for logging the data.
    I know that using the abap mapping I can parse an XML file. My question is how to write this table defining a specific method, if it is necessary.
    Any help or suggestion is well appreciated.
    Many thanks in advance for your kind cooperation.
    Regards,
      Giovanni

    hi,
    >> My question is how to write this table defining a specific method, if it is necessary.
    just like to normal table (insert statement)
    parse XML and get the data you need and just insert into the DB table
    there are many tutorials showing how to parse xml file inside abap mapping
    so just do a little search on sdn
    Regards,
    Michal Krawczyk

  • How to write a Xml installation file to build  web installer using IzPack.

    Hai everyone,
    I have got a problem in building a web installer using IzPack.I am getting this exception,when I am compiling my install.xml using a compile tool provided by IzPack soft.Eventhough I have not mentioned "packsinfo.xml" in my Xml installation file.
    Fatal error :
    null\packsinfo.xml (The system cannot find the path specified)
    java.io.FileNotFoundException: null\packsinfo.xml (The system cannot find the path specified)
    What went wrong??
    It is very very urgent. Could anyone tell me how to write a Xml installation file for building web installer,please??
    any help will be highly appreciated....
    Thank you very much in advance

    Hi,
    that is not really a java related question. Have you tried to find some IzPack support forum? I've never heard about it, so I can't help.

  • How to write a file using mod pl/sql

    hi,
    i am having a submit button in my procedure. which should inturn create .sql file in a file path.
    is there any way to create a fileusing htp and htf methods.
    Thanks in advance
    Hari

    >
    i am having a submit button in my procedure. which should in turn create .sql file in a file path.
    is there any way to create a file using htp and htf methods.
    >
    Why are you wasting your time coding from scratch using the PL/SQL Web Toolkit instead of the APEX framework?
    From Re: how to write a file using mod pl/sql it appears that you are not using APEX, so a number of the approaches APEX offers are not relevant. You appear to be looking for a file download solution using the <tt>wpg_docload.download_file</tt> method, such as:
    create or replace procedure download_file (
        p_filename  in     varchar2
      , p_mimetype  in     varchar2
      , p_content   in out nocopy blob)
    is
    begin
      -- Set up HTTP header.
      -- Use "application/octet" as default MIME type.
      owa_util.mime_header(nvl(p_mimetype, 'application/octet'), false);
      -- Set the size so the browser knows how much to download.
      htp.p('Content-length: ' || dbms_lob.getlength(p_content));
      -- Filename will be used as default by the browser in "Save as..."
      htp.p('Content-Disposition: attachment; filename="' || p_filename || '"');
      -- Close header.
      owa_util.http_header_close();
      -- Stream the file content to the browser.
      wpg_docload.download_file(p_content);
    end download_file;

Maybe you are looking for

  • "Motion and Compressor Will Not Open Because Of A Problem"?

    Last week I installed FCS 3 on my iMac and everything appeared to work OK. However, as my iMac had been cluttered with rubbish for 2 years I erased the Hard Drive and reinstalled OSX 10.6.3 together with all FCS 3. I have only used FCP and STP since

  • OS 10.9.4 Startup animation missing

    Hello, in order to spare some HD space in /private/var/folders I did a safe startup. After that procedure the animation right before the login screen during the startup procedure is missing. I know the issue is more cosmetic than serious but the bug

  • Master data number range, Free goods

    Hi All, Can any one tell me, what is the requirement of deletion of number range? normallly for number range deletion you have to initialize it,(I am writing about master data number range). What customization is required for free goods from MM presp

  • CS4: Setup problems

    Hello everybody. I have the following problem: I've downloaded CS4 trial from adobe.com, but when I run setup.exe, nothing happens. Setup.exe is running in task manager, but...nothing. The same installation package works on my friend's PC. I have all

  • Want to update the operating systems to Mountain Lion version 10.8.2

    Want to update the operating systems to Mountain Lion version 10.8.2 on my Macbook6,1 from Mac OS X Version 10.6.8. Will this affect the performance of my computer in a negative way, and if the benefits outweigh it? Thanks.