Obj PageContext null in a Custom Tag

Hi Every body
I'm Mauricio and my problem is :
I did a Custom tag and when I invoke it the PageContext object in the tag is null, I don't know why.
Any suggestion about the reason of this problem, will be a great help.
The source of Custom tag is :
package expert.esecurity.tag;
import java.io.IOException;
import javax.servlet.ServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport;
public class SE_TagDynamicAction extends TagSupport
private PageContext objPageContext;
private String sbClazz;
private String sbMethod;
public void setPageContext(PageContext objPageContext)
this.objPageContext = objPageContext;
public void setSbClazz(String sbClazz)
this.sbClazz = sbClazz;
public void setSbMethod(String sbMethod)
this.sbMethod = sbMethod;
public int doStartTag() throws JspException
try
if(objPageContext!=null){ //the obj objPageContext is null
JspWriter out = pageContext.getOut();
ServletRequest objServletRequest = pageContext.getRequest();
     //Do the functionality and print reult
     out.print( result );
else{
throw new JspException("Object pageContext of the SE_TagDynamicAction tag is null");
catch (BA_UTException objBA_UTException)
throw new JspException(objBA_UTException.getMessage());
catch (IOException objIOException)
throw new JspException(objIOException.getMessage());
return SKIP_BODY;
public int doEndTag()
return EVAL_PAGE;
}

Your setPageContext didn't make the context null, the context was never null. YOUR objPageContext, however, was null.
Did you notice that you were checking for the existing of YOUR objPageContext (i.e != null) yet you were pulling, however you were pulling the request and writers from the default pageContext:
try
if(objPageContext !=null){ //the obj objPageContext is null
JspWriter out = pageContext.getOut(); // See, you didn't use objPageContext.getOut();
ServletRequest objServletRequest = pageContext.getRequest();// or objPageContext.getRequest();
//Do the functionality and print reult
out.print( result );
else{
throw new JspException("Object pageContext of the SE_TagDynamicAction tag is null");
}The point is, the setPageContext method is not guaranteed to be invoked by the system, this is there so YOU can assign a different pageContext if necessary. Therefore the setPageContext method was never called (as you never explicitly called it) and therefore your objPageContext was null. BUT, the default pageContext class variable was NOT null.
HTH.

Similar Messages

  • Custom Tag using object as an attribute.

    I have read up on trying to pass an object as an attribute to a custom tag.
    Is it true that the only way to do this is to put the object, using a "key name" in the pageContext
    Then in the custom tag, set an attribute equal to the "Key Name"
    Then in the TagHandler, to do a lookup using the "Key Name"
    We can not just past objects into the attribute?
    And what is this about using EL or JSP2.0
    sorry sort of new to the whole game.

    Certainly you can pass objects to tags.
    However you need to use a runtime expression to do that.
    such as <%= expr %> or (with JSP2.0) ${expr}
    If you look at the JSTL library, it uses the EL and passes in objects all the time. However the EL actually accesses the page/request etc attributes as its variable space, so you are still technically using attributes.
    Is it true that the only way to do this is to put the object, using a "key name" in the pageContext
    then in the custom tag, set an attribute equal to the "Key Name"
    then in the TagHandler, to do a lookup using the "Key Name"That is one way of doing it. The struts libraries use this method extensively. It is more suited to JSP1.2.
    Sometimes it is easier/neater just to put the value into a scoped attribute, and pass in the name of that attribute. That way you don't need to worrry about the type of the attribute at all in your JSP.
    Hope this helps some,
    evnafets

  • Help! pageContext is NULL in custom tag constructor!

    I'm having a problem with a custom tag class, and I'm not sure whether it's because I'm doing something wrong, or because I'm running into a bug with Tomcat, JDK1.4b2, or something else. Basically, I'm finding that the pageContext object is null in the constructor of a custom tag class... something that I'm pretty sure is NOT supposed to happen.
    I'm running JDK1.4b2 with Forte CE 3.1 (the bug predates the jumbo fix that brought it up to 3.0) and using Forte's embedded Tomcat.
    I'm not sure whether it matters, but here's the sequence of events:
    A servlet gets launched,
    instantiates an object of type Error_list,
    binds Error_list to the request object, and
    forwards to a JSP that uses the custom tag defined by ListErrorsTag.
    Unfortunately, pageContext is null in ErrorListTag's constructor, so the attempt to get the request object from the pageContext object generates a NullPointerException.
    The SERVLET: *****************************************
    // relevant lines from the servlet instantiating the object, binding it, and forwarding...
         Error_list errors = new Error_list("BAD_THINGS", "crash and burn");
         request.setAttribute("errors",errors);
         ServletContext sc = this.getServletContext();
         RequestDispatcher rd = sc.getRequestDispatcher("admin_category_create.jsp");
         rd.forward(request,response);
    The JSP: ************************************************
    In the JSP "admin_category_create.jsp" itself, I specify the taglib:
         <%@ taglib uri='/WEB-INF/AdminTags.tld' prefix = 'admin' %>
    and reference it:
         <admin:listErrors>The errors will be listed here</admin:listErrors>
    The Explosion of the Taglib: ************************
    // beginning of Taglib class:
    public class ListErrorsTag extends BodyTagSupport {
        private Error_list errors;
        public ListErrorsTag() {
        super()
        try {
             if (pageContext == null)
                 System.out.println("uh oh! pageContext is null");
             ServletRequest request = pageContext.getRequest();
             errors = (Error_list)request.getAttribute("errors");
        catch (NullPointerException e) {
             System.out.println("boom!");
    The Result: **************************************
    Tomcat's error log:
    uh oh! pageContext is null
    boom!
    if I eliminate the try/catch and allow the NullPointerException to take place, I get:
    Error: 500
    Location: /admin_category_create.jsp
    Internal Servlet Error:
    javax.servlet.ServletException
         at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:459)
         at _0002fadmin_0005fcategory_0005fcreate_0002ejspadmin_0005fcategory_0005fcreate_jsp_0._jspService(_0002fadmin_0005fcategory_0005fcreate_0002ejspadmin_0005fcategory_0005fcreate_jsp_0.java:338)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:177)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
         at org.netbeans.modules.web.tomcat.JspServlet.service(JspServlet.java:91)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
         at org.apache.tomcat.core.Handler.service(Handler.java:286)
         at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
         at org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:194)
         at admin.processRequest(admin.java:126)
         at admin.doPost(admin.java:144)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
         at org.apache.tomcat.core.Handler.service(Handler.java:286)
         at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
         at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
         at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
         at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
         at java.lang.Thread.run(Thread.java:539)
    Root cause:
    java.lang.NullPointerException
         at AdminTags.ListErrorsTag.(ListErrorsTag.java:32)
         at _0002fadmin_0005fcategory_0005fcreate_0002ejspadmin_0005fcategory_0005fcreate_jsp_0._jspService(_0002fadmin_0005fcategory_0005fcreate_0002ejspadmin_0005fcategory_0005fcreate_jsp_0.java:272)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:177)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
         at org.netbeans.modules.web.tomcat.JspServlet.service(JspServlet.java:91)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
         at org.apache.tomcat.core.Handler.service(Handler.java:286)
         at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
         at org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:194)
         at admin.processRequest(admin.java:126)
         at admin.doPost(admin.java:144)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
         at org.apache.tomcat.core.Handler.service(Handler.java:286)
         at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
         at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
         at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
         at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
         at java.lang.Thread.run(Thread.java:539)

    Doing a little more experimentation, I discovered that pageContext is null in the constructor, but not null in the otherDoStartTagOperations() method (called by the doStartTag() method of the tag's class... it's something Forte forces you to do).
    Is this normal? I was under the impression that pageContext is supposed to be defined EVERYWHERE in any class that extends BodyTagSupport... including the class' own constructor.
    On a related topic, is there documentation somewhere as to what, exactly, Forte is doing behind the scenes when it's managing a taglib (how it keeps track of them, where it puts config files, how the entries it makes in them are different or extended from the normal layout, etc.)? At the moment, I suspect that half of the grief I'm having with writing taglibs is caused by Forte itself forcing me to do things in a roundabout way that bears little resemblance to the ways shown in different books on the topic (and in fact all but ensures that nearly every published example will fail and require major rewriting because of the way it forces tag classes to be structured), but I don't see any easy way to let Forte handle compiling the classes and testing them with its embedded Tomcat, but do the config file housekeeping myself I can be in control of it.

  • PageContext in Custom tag?

    Hi,
    How can a custom tag handler obtain instance of PageContext?

    Hi
    When you extend TagSupport or BodyTagSupport the "pageContext" object which is a protected member of the TagSupport class is automatically available to your TagHandler class.
    Keep me posted.
    Good Luck!
    Eshwar Rao
    Developer Technical Support
    Sun microsystems
    http://www.sun.com/developers/support

  • Exception while passing null as param in custom tag

    Hi,
    I am using Oracle 10g AS(10.1.2). In my j2ee application,while passing NULL as parameter in custom tags, i am getting exception. But it was working fine with oracle 9i as.
    for example:
    This is my code in jsp:
    <%
    String str =null;
    %>
    <test:getInfo id="<%=str%>" />
    While executing the above code, I am getting the following exception :
    javax.servlet.ServletException
    at com.evermind.server.http.EvermindPageContext.handlePageThrowable(EvermindPageContext.java:595)
    at com.evermind.server.http.EvermindPageContext.handlePageException(EvermindPageContext.java:537)
    at ListAlerts.jspService(_ListAlerts.java:1827)
    at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
    at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:350)
    at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509)
    at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
    at com.evermind.server.http.ServletRequestDispatcher.include(ServletRequestDispatcher.java:121)
    at com.evermind.server.http.GetParametersRequestDispatcher.newInclude(GetParametersRequestDispatcher.java:80)
    at com.evermind.server.http.GetParametersRequestDispatcher.include(GetParametersRequestDispatcher.java:34)
    at com.evermind.server.http.EvermindPageContext.include(EvermindPageContext.java:267)
    at Content.jspService(_Content.java:181)
    at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
    at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:350)
    at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509)
    at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
    at com.evermind.server.http.ServletRequestDispatcher.include(ServletRequestDispatcher.java:121)
    at com.evermind.server.http.GetParametersRequestDispatcher.newInclude(GetParametersRequestDispatcher.java:80)
    at com.evermind.server.http.GetParametersRequestDispatcher.include(GetParametersRequestDispatcher.java:34)
    at com.evermind.server.http.EvermindPageContext.include(EvermindPageContext.java:267)
    at Main.jspService(_Main.java:360)
    at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
    at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:350)
    at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509)
    at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
    at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:222)
    at org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.java:845)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:734)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:98)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
    at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:224)
    at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:133)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
    at java.lang.Thread.run(Thread.java:534)
    Please help me....

    Hello,
    I do not remember exactly how the null where handle in Oracle 9iAS. Have you tested what is the differences in the way the <%= null %> is returned in both 9iAS and 10.1.2?
    You may just have to modify the way the value is sent to the bean from the tag.
    Regards
    Tugdual Grall

  • Custom tag attributes and rtexprvalue property

    I have created a custom tag. In my .tld file I have added <rtexprvalue>true</rtexprvalue>
    for several of the tag's attributes. Now I want to be able to pass values to
    these attributes with the expression syntax:
    eg <mytagprefix:pager maxRecordCount="{pageFlow.maxRecords}" />
    where maxRecords is a public variable in my pageflow.
    In my tag code to assign the value of maxRecordCount I have the following:
    public void setMaxRecordCount(String maxRecordCount) throws JspException
    Object obj = null;
    obj = evaluateExpression(maxRecordCount, "maxRecordCount");
    if(hasErrors())
    reportErrors();
    localRelease();
    else
    pb.setMaxRecordCount(new Long(((String) obj)).longValue());
    I keep getting compile time errors in my jsp such as:
    Error: no match was found for method setMaxRecordCount(long) in type package.PagerTag.
    where package is the package of my custom class PagerTag.
    In my pageflow maxRecordCount is a String. I don't understand why it is looking
    for a long. Sometimes the error goes away and I thought I had gotten it to work
    but then I realized that it was only working as long as the name of my attribute
    and the name of my public variable matched and that is not what I wanted to do.
    Should I be able to do what I am doing? I can instead pass this to the tag:
    <netui-data:getData resultId="maxreccount" value="{pageFlow.maxRecordCount}" />
    maxRecordCount="<%=(String) pageContext.getAttribute(\"maxreccount\")%>"
    but that is much less convenient.
    Thanks for any help.
    Robin

    Hello,
    Yes I forgot to include the faces xml DD. Here are the portions of code relating to the component and renderers:
    <render-kit>
    <renderer>
    <component-family>MyFamily</component-family>
    <renderer-type>MyRenderer</renderer-type>
    <renderer-class>essaisUn.MyRenderer</renderer-class>
    </renderer>
    </render-kit>
    <component>
    <component-type>MyComponent</component-type>
    <component-class>essaisUn.MyComponent</component-class>
    <component-extension>
    <component-family>MyFamily</component-family>
    <renderer-type>MyRenderer</renderer-type>
    </component-extension>
    </component>I changed from "<hello>" to "hello" and I still get the same exception.
    Can anyone bail me out?
    Thanks in advance,
    Julien Martin.

  • Rendering A JPEG image with a custom tag

    Hi All,
    I have dilema. I'm trying to rendering a jpeg in IE/FireFox with a custom tag that I developed. I'm able to access the bean and invoke the getter method to return the InputStream property. But what gets rendered is the byte code not the image. I've tried just about anything I could think off. If any body has an answer I would difinitely appreciate it.
    Thanks,
    Tony
    Below is the jsp, tld, bean and tag.
    ********************************* image.jsp ****************************************
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@ taglib uri="/WEB-INF/custom-chtml.tld" prefix="chtml" %>
    <html>
    <head>
    <title>HTML Page</title>
    </head>
    <body bgcolor="#FFFFFF">
    <chtml:img name="photo" property="file"/>
    </body>
    </html>
    ********************************* custom-chtml.tld **********************************
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
    <taglib>
    <tlibversion>1.0</tlibversion>
    <jspversion>1.1</jspversion>
    <shortname>chtml</shortname>
    <tag>
    <name>img</name>
    <tagclass>com.struts.taglib.CustomImgTag</tagclass>
    <bodycontent>empty</bodycontent>
    <attribute>
    <name>name</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
    <name>property</name>
    <required>true</required>
    <rtexprvalue>true</rtexprvalue>
    </attribute>
    </tag>
    </taglib>
    **************************** MemberPhotoBean.java ******************************
    import java.io.InputStream;
    * @author tony
    * TODO To change the template for this generated type comment go to
    * Window - Preferences - Java - Code Style - Code Templates
    public class MemberPhotoValue {
         private String memberId;
         private int fileSize;
         private InputStream file;
         public MemberPhotoValue() {
         public MemberPhotoValue(String memberId, InputStream file) {
              this.memberId = memberId;
              this.file = file;
         public MemberPhotoValue(String memberId,int fileSize,InputStream file) {
              this.memberId = memberId;
              this.fileSize = fileSize;
              this.file = file;          
         public String getMemberId(){
              return memberId;
         public void setMemberId(String memberId) {
              this.memberId = memberId;
         public int getFileSize() {
              return fileSize;
         public void setFileSize(int fileSize) {
              this.fileSize = fileSize;
         public InputStream getFile(){
              return file;
         public void setFile(InputStream file) {
              this.file = file;
    *************************** CustomTagHandler.java ********************************
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.servlet.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    import java.lang.reflect.Method;
    import java.lang.reflect.InvocationTargetException;
    import java.awt.image.*;
    import java.awt.*;
    import javax.swing.ImageIcon;
    import com.sun.image.codec.jpeg.*;
    * JSP Tag Handler class
    * @jsp.tag name = "CustomImg"
    * display-name = "Name for CustomImg"
    * description = "Description for CustomImg"
    * body-content = "empty"
    public class CustomImgTag implements Tag {
         private PageContext pageContext;
         private Tag parent;
         private String property;
         private String name;
         private Class bean;
         public int doStartTag() throws JspException {
              return SKIP_BODY;
         public int doEndTag() throws JspException {
         try {
         ServletResponse response = pageContext.getResponse();
         // read in the image from the bean
         InputStream stream = (InputStream) invokeBeanMethod();
         BufferedImage image = ImageIO.read(stream);          Image inImage = new ImageIcon(image).getImage();
         Graphics2D g = image.createGraphics();
         g.drawImage(inImage,null,null);               
         OutputStream out = response.getOutputStream();
    // JPEG-encode the image
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    encoder.encode(image);               
         out.close();     
    } catch (IOException io) {
              throw new JspException(io.getMessage());
         return EVAL_PAGE;
         public void release(){}
    private InputStream invokeBeanMethod() throws JspException {
         try {
         Object bean = null;
         if (null != pageContext.getAttribute(name)) {
         bean = (Object) pageContext.getAttributename);
         else if (null != pageContext.getSession().getAttribute(name)) {
         bean = (Object) pageContext.getSession().getAttribute(name);
         else if (null != pageContext.getRequest().getAttribute(name)) {
         bean = (Object) pageContext.getRequest().getAttribute(name);
         else {
         throw new JspException("Bean : "+name+" is not found in any pe.");
         Class[] parameters = null;
         Object[] obj = null;               
         Method method = bean.getClass().getMethod("getFile",parameters);
         return (InputStream) method.invoke(bean,obj);
         } catch (NoSuchMethodException ne) {
         throw new JspException("No getter method "+property+" for bean : "+bean);
         } catch (IllegalAccessException ie) {
         throw new JspException(ie.getMessage());
         } catch (InvocationTargetException ie) {
         throw new JspException(ie.toString());
         public void setPageContext(PageContext pageContext) {
              this.pageContext = pageContext;
         public void setParent(Tag parent) {
              this.parent = parent;
         public Tag getParent() {
              return parent;
         public void setProperty(String property) {
              this.property = property;
         public void setName(String name) {
              this.name = name;
    **************************************************************************************

    If you have access to an image editing tool such as photoshop, I would advice you import the image into Phototshop and save it in a different format e.g, GIF format and re-import it into Final Cut Express HD. This could solve your rendering problem if all you need is to use a Still image.
    Ayemenre

  • Why doesn't my custom tag work?

    First, my backend database is MS Access. Nothing I can do about that, unfortunately.
    I have defined three custom tags (no body, no attributes) to display report information from my project tracking/metrics Access database:
    <prefix:showProjectInfo />
    <prefix:showProjectTeam />
    <prefix:showProjectHistory />
    In my JSP, the first tag I use, <prefix:showProjectInfo />, works perfectly. However, <prefix:showProjectTeam /> gives no output.
    First, here is the tld file that defines the tags (report.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/dtd/web-jsptaglibrary_1_2.dtd">
    <taglib>
        <tlib-version>1.0</tlib-version>
        <jsp-version>1.2</jsp-version>
        <short-name>report</short-name>
        <uri>/report</uri>   
        <!-- Forte4J_TLDX:  This comment contains code generation information. Do not delete.
        <tldx>
            <tagHandlerGenerationRoot>classes</tagHandlerGenerationRoot>
        </tldx>
        -->
        <!-- A validator verifies that the tags are used correctly at JSP
             translation time. Validator entries look like this:
          <validator>
              <validator-class>com.mycompany.TagLibValidator</validator-class>
              <init-param>
                 <param-name>parameter</param-name>
                 <param-value>value</param-value>
           </init-param>
          </validator>
       -->
       <!-- A tag library can register Servlet Context event listeners in
            case it needs to react to such events. Listener entries look
            like this:
         <listener>
             <listener-class>com.mycompany.TagLibListener</listener-class>
         </listener>
       -->
       <tag>
            <name>showProjectInfo</name>
            <tag-class>mil.usaf.rad.metrics.report.showProjectInfoTag</tag-class>
            <body-content>empty</body-content>
            <description>Shows the basic project information</description>       
       </tag>
       <tag>
            <name>showProjectTeam</name>
            <tag-class>mil.usaf.rad.metrics.report.showProjectTeamTag</tag-class>
            <body-content>empty</body-content>
       </tag>
       <tag>
            <name>showProjectHistory</name>
            <tag-class>mil.usaf.rad.metrics.report.showProjectHistoryTag</tag-class>
            <body-content>empty</body-content>
       </tag>
    </taglib>Next, here is the relevant section of web.xml that defines this taglib:
      <taglib>
            <taglib-uri>/WEB-INF/report.tld</taglib-uri>
            <taglib-location>/WEB-INF/report.tld</taglib-location>
      </taglib>Next, the code for showProjectTeamTag.java:
    * showProjectTeam.java
    * Created on March 9, 2005, 10:46 AM
    package mil.usaf.rad.metrics.report;
    import java.io.*;
    import java.sql.*;
    import java.lang.Integer;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    * @author  jason.ferguson
    public class showProjectTeamTag extends TagSupport
        public showProjectTeamTag()
            super();
        public int doAfterBody() throws JspException
            HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
            int pr_id = Integer.parseInt(req.getParameter("pr_id"));
            JspWriter out = pageContext.getOut();
            Connection conn = null;
            Statement stmt = null;
            ResultSet rs = null;
            try
               out.print("test");
               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
               conn = DriverManager.getConnection("jdbc:odbc:Metrics");
            catch (Exception e)
                throw new JspException(e.getMessage());
            String queryGetTeam = "SELECT Projects.pr_id, Accounts.name AS Name, Sum(Schedule.hours) AS SumOfhours FROM tblTAAccounts AS Accounts INNER JOIN ((tblTAScheduleEntries AS Schedule INNER JOIN tblProjectRelease AS ProjectRelease ON Schedule.projectID = ProjectRelease.tblFKTimeAccntProject) INNER JOIN tblPMProjects AS Projects ON ProjectRelease.Release_ID = Projects.pr_id) ON Accounts.accountID = Schedule.accountID WHERE Projects.pr_id=" + pr_id + " GROUP BY Projects.pr_id, Accounts.name, ProjectRelease.Release_number, Projects.Project_name";
            try
                out.print(queryGetTeam);
                stmt = conn.createStatement();
                rs = stmt.executeQuery(queryGetTeam);
                if (rs == null)
                    out.print("No Results!");
                out.print("<table>\n");
                out.print("<tr>\n");
                out.print("<th>Name</th>\n");
                out.print("<th>Total Hours</th>\n");
                out.print("</tr>\n");
                while(rs.next())
                    out.print("<tr>\n");
                    out.print("<td>" + rs.getString("Name") + "</td>\n");
                    out.print("<td>" + rs.getInt("SumOfhours") + "</td>\n");
                    out.print("</tr>\n");
                out.print("</table>\n");
                rs.close();
                stmt.close();
                conn.close();
            catch (Exception e)
                throw new JspException(e.getMessage());
            return SKIP_BODY;
    }Finally, projectdetail.jsp, where the tag is called:
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@page import="java.sql.*" %>
    <%@page import="java.lang.Integer" %>
    <%@taglib uri="/WEB-INF/report.tld" prefix="report" %>
    <html>
    <head><title>Project Detail</title></head>
    <body>
    <h1 align="center">Project Status</h1>
    <h3>Project Description</h3>
    <report:showProjectInfo />
    <h3>Team Members</h3>
    <report:showProjectTeam />
    </body>
    </html>The first tag, <report:showProjectInfo />, works fine. However, I get no output whatsoever when the system encounters <report:showProjectTeam />. I am a relative newbie at this, so any help is appreciated.
    Jason

    It doesnt seem to matter if the code is in doStartTag(), doEndTag(), orr any of the other functions.
    I also put, as the first item in the function:
    System.out.println("TEST");Nothing.
    Just as an aside, here is the code for the <prefix:showProjectInfo />. Maybe I made a mistake in it? I closed the resultset and connection...
    import java.io.*;
    import java.sql.*;
    import java.lang.Integer;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    * @author  jason.ferguson
    public class showProjectInfoTag extends BodyTagSupport
        public int doEndTag() throws JspException
            HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
            int pr_id = Integer.parseInt(req.getParameter("pr_id"));
            JspWriter out = pageContext.getOut();
            Connection conn = null;
            Statement stmt = null;
            ResultSet rs = null;
            try
               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                conn = DriverManager.getConnection("jdbc:odbc:Metrics");
            catch (Exception e)
                throw new JspException(e.getMessage());
            String queryProjectInfo = "SELECT * FROM tblPMProjects WHERE pr_id=" + pr_id;
            try
                stmt = conn.createStatement();
                rs = stmt.executeQuery(queryProjectInfo);
                while (rs.next())
                    out.print("<table border=\"1\" style=\"border-collapse:collapse\">\n");
                    out.print("<tr>\n");
                    out.print("<td><b>Project Name:</b>" + rs.getString("Project_name") + "</td>\n");
                    out.print("<td align=\"right\"><b>RAD Number:</b>" + rs.getString("tblProjectNumber") + "</td>\n");
                    out.print("</tr>\n");
                    out.print("<tr>\n");
                    out.print("<td>Project description: " + rs.getString("Project_description") + "</td>\n");
                    out.print("</tr>\n");
                    out.print("<tr>\n");
                    out.print("<td>Customer: " + rs.getString("Customer_POC") + "</td>");
                    out.print("<tr>\n");
                    out.print("<tr>\n");
                    out.print("<td>Customer Unit: " + rs.getString("Customer_OFC") + "</td>\n");
                    out.print("</tr>\n");
                    out.print("<tr>\n");
                    out.print("<td>Customer Phone: " + rs.getString("Customer_phone") + "</td>\n");
                    out.print("</tr>\n");
                    out.print("</table>\n");
                    rs.close();
                    stmt.close();
                    conn.close();
            catch (Exception e)
                throw new JspException(e.getMessage());
            finally
                //conn.close();
            return SKIP_BODY;

  • Connection Pooling and JSP Custom Tag Library - is code (inside) the best way/correc?

    Hi, can anyone advise as to whether my tag library code (based
    on Apache Jakarta Project) will actually achieve connection
    pooling functionality across my entire JSP based application? I
    am slightly concerned that my OracleConnectionCacheImpl object
    may exist multiple times, hence rendering my conection pooling
    attempt useless.
    package com.solved.tag.dbtags.connection;
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.SQLException;
    import javax.servlet.jsp.tagext.TagSupport;
    import javax.servlet.jsp.JspTagException;
    import javax.sql.DataSource;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import oracle.jdbc.pool.OracleConnectionCacheImpl;
    * <p>JSP tag connection, used to get a
    * java.sql.Connection object.</p>
    * <p>JSP Tag Lib Descriptor
    * <pre>
    * &lt;name>connection&lt;/name>
    &lt;tagclass>com.solved.tag.dbtags.connection.ConnectionTag&lt;/t
    agclass>
    * &lt;bodycontent>JSP&lt;/bodycontent>
    &lt;teiclass>com.solved.tag.dbtags.connection.ConnectionTEI&lt;/t
    eiclass>
    * &lt;info>Opens a connection based on a jndiName.&lt;/info>
    * &lt;attribute>
    * &lt;name>id&lt;/name>
    * &lt;required>true&lt;/required>
    * &lt;rtexprvalue>false&lt;/rtexprvalue>
    * &lt;/attribute>
    * </pre>
    * @author Matt Shannon
    public class ConnectionTag extends TagSupport {
    static private OracleConnectionCacheImpl cache = null;
    public int doStartTag() throws JspTagException {
    try {
    Connection conn = null;
    if (cache == null) {
    try {
    InitialContext ic = new InitialContext();
    DataSource ds = (DataSource) ic.lookup
    ("jdbc/pool/OracleCache");
    cache = (OracleConnectionCacheImpl)ds;
    catch (NamingException ne) {
    throw new JspTagException(ne.toString());
    conn = cache.getConnection();
    pageContext.setAttribute(getId(),conn);
    catch (SQLException e) {
    throw new JspTagException(e.toString());
    return EVAL_BODY_INCLUDE;
    package com.solved.tag.dbtags.connection;
    import java.sql.Connection;
    import java.sql.SQLException;
    import javax.servlet.jsp.tagext.TagSupport;
    * <p>JSP tag closeconnection, used to close the
    * specified java.sql.Connection.<p>
    * <p>JSP Tag Lib Descriptor
    * <pre>
    * &lt;name>closeConnection&lt;/name>
    &lt;tagclass>com.solved.tag.dbtags.connection.CloseConnectionTag&
    lt;/tagclass>
    * &lt;bodycontent>empty&lt;/bodycontent>
    * &lt;info>Close the specified connection. The "conn"
    attribute is the name of a
    * connection object in the page context.&lt;/info>
    * &lt;attribute>
    * &lt;name>conn&lt;/name>
    * &lt;required>true&lt;/required>
    * &lt;rtexprvalue>false&lt;/rtexprvalue>
    * &lt;/attribute>
    * </pre>
    * @author Matt Shannon
    * @see ConnectionTag
    public class CloseConnectionTag extends TagSupport {
    private String _connId = null;
    * The "conn" attribute is the name of a
    * page context object containing a
    * java.sql.Connection.
    * @param connectionId
    * attribute name of the java.sql.Connection to
    close.
    * @see ConnectionTag
    public void setConn(String connectionId) {
    _connId = connectionId;
    public int doStartTag() {
    try {
    Connection conn = (Connection)pageContext.getAttribute
    (_connId);
    conn.close();
    } catch (SQLException e) {
    // failing to close a connection is not fatal
    e.printStackTrace();
    return EVAL_BODY_INCLUDE;
    public void release() {
    _connId = null;
    package com.solved.tag.dbtags.connection;
    import javax.servlet.jsp.tagext.TagData;
    import javax.servlet.jsp.tagext.TagExtraInfo;
    import javax.servlet.jsp.tagext.VariableInfo;
    * TagExtraInfo for the connection tag. This
    * TagExtraInfo specifies that the ConnectionTag
    * assigns a java.sql.Connection object to the
    * "id" attribute at the end tag.
    * @author Matt Shannon
    * @see ConnectionTag
    public class ConnectionTEI extends TagExtraInfo {
    public final VariableInfo[] getVariableInfo(TagData data)
    return new VariableInfo[]
    new VariableInfo(
    data.getAttributeString("id"),
    "java.sql.Connection",
    true,
    VariableInfo.AT_END
    data-sources.xml:
    <?xml version="1.0"?>
    <!DOCTYPE data-sources PUBLIC "Orion data-
    sources" "http://xmlns.oracle.com/ias/dtds/data-sources.dtd">
    <data-sources>
    <data-source
    class="oracle.jdbc.pool.OracleConnectionCacheImpl"
    name="jdbc/pool/OracleCache"
    location="jdbc/pool/OracleCache"
    url="jdbc:oracle:thin:@oracle1:1521:pdev"
    >
    <property name="maxLimit" value="15" />
    <property name="cacheScheme" value="2" />
    <property name="user" value="console" />
    <property name="password" value="console" />
    <description>
    This DataSource is using an Oracle-native DataSource Class so as
    to allow Oracle Specific extensions.
    A getConnection() call on this DataSource will return
    oracle.jdbc.driver.OracleConnection.
    The connection returned is a logical connection.
    The caching scheme in place is Fixed Wait. Refer below to
    possible values.
    Dynamic 1
    Fixed Wait 2
    Fixed Return Null 3
    </description>
    </data-source>
    </data-sources>
    many thanks,
    Matt.

    Hi. Show me your pool definition.
    Joe
    Ramamurthy wrote:
    I am using the jsp custom tag library from BEA called sqltags.tld which came with Weblogic 5.1. Currently I am using Weblogic6.1 sp2 on Solaris.
    I have created a Connection Pool for Sybase database using the driver com.sybase.jdbc.SybDriver.
    When I created jsp page to connect to the connection pool using sqltags custom tag library, I am getting the error
    "javax.servlet.jsp.JspException: Failed to write body content
    at weblogic.taglib.sql.ConnectionTag.doAfterBody(ConnectionTag.java:43)
    at jsp_servlet.__hubwcdata._jspService(__sampletest.java:1014)"
    After this message, whenever I try to access the same jsp page I am getting the message
    "javax.servlet.jsp.JspException: Failed to load JDBC driver: weblogic.jdbc.pool.D
    river
    at weblogic.taglib.sql.ConnectionTag.doStartTag(ConnectionTag.java:34)
    at jsp_servlet.__hubwcdata._jspService(__sampletest.java:205)".
    Can you please help me the reason why this problem is happening and how to fix this ?
    This problem doexn't happen consistently. This occurs once in a while.
    I tried to increase Login delay Seconds parameter in the Connection Pool to 15 sec. It didn't help me much.
    Thanks for your help !!!
    Ram

  • Runtime failure in custom tag

              I was curious if you knew what specifically you did to remove the runtime error.
              I am also getting the runtime failure. The try/catch that another discussion thread
              suggested does not catch the error since the exception is thrown prior to the
              doStart and doEnd Tag methods. I know that the exception is thrown immediately
              after the constructor is called for the tag and before the setParent method is
              called.
              Anyway, thank you in advance for any suggestions you might have.
              try { // begin instantiate/release try/catch/finally block... //[ /wattage/wtgMainMenu.jsp;
              Line: 36]
                   westerncommon_jsptag_HeaderTag_0 = (western.common.jsptag.HeaderTag)java.beans.Beans.instantiate(getClass().getClassLoader(),
              "western.common.jsptag.HeaderTag"); //[ /wattage/wtgMainMenu.jsp; Line: 36]
              westerncommon_jsptag_HeaderTag_0.setPageContext(pageContext); //[ /wattage/wtgMainMenu.jsp;
              Line: 36]
              westerncommon_jsptag_HeaderTag_0.setParent(null); //[ /wattage/wtgMainMenu.jsp;
              Line: 36]
                   westerncommon_jsptag_HeaderTag_0.setNavMenuHREF(weblogic.utils.StringUtils.valueOf("wtgLogout.jsp"));
              //[ /wattage/wtgMainMenu.jsp; Line: 36]
              westerncommon_jsptag_HeaderTag_0.setNavMenu(weblogic.utils.StringUtils.valueOf("Logout"));
              //[ /wattage/wtgMainMenu.jsp; Line: 36]
              westerncommon_jsptag_HeaderTag_0.setTitle(weblogic.utils.StringUtils.valueOf("Main
              Menu")); //[ /wattage/wtgMainMenu.jsp; Line: 36]
              int int0 = westerncommon_jsptag_HeaderTag_0.doStartTag(); //[ /wattage/wtgMainMenu.jsp;
              Line: 36]
                   if (_int_0 == BodyTag.EVAL_BODY_TAG) { //[ /wattage/wtgMainMenu.jsp; Line: 36]
                        throw new JspTagException("Since tag class western.common.jsptag.HeaderTag does
              not implements BodyTag, it cannot return BodyTag.EVAL_BODY_TAG"); //[ /wattage/wtgMainMenu.jsp;
              Line: 36]
              } //[ /wattage/wtgMainMenu.jsp; Line: 36]
              /*** sync AT_BEGIN TagExtra Vars here ***/ //[ /wattage/wtgMainMenu.jsp;
              Line: 36]
              if (_int_0 != Tag.SKIP_BODY) { // begin !SKIP_BODY... //[ /wattage/wtgMainMenu.jsp;
              Line: 36]
                        //[ /wattage/wtgMainMenu.jsp; Line: 36]
                        out.print("\r\n");
                             //[ /wattage/wtgMainMenu.jsp; Line: 37]
                   } // end !SKIP_BODY //[ /wattage/wtgMainMenu.jsp; Line: 37]
              if (_western_common_jsptag_HeaderTag_0.doEndTag() == Tag.SKIP_PAGE) return;
              //[ /wattage/wtgMainMenu.jsp; Line: 37]
              } catch (java.lang.Exception javalang_Exception_0) { // instantiate/release
              try/catch/finally //[ /wattage/wtgMainMenu.jsp; Line: 37]
                   throw new ServletException("runtime failure in custom tag 'HeaderTag'", javalang_Exception_0);
              //[ /wattage/wtgMainMenu.jsp; Line: 37]
              } finally { // instantiate/release try/catch/finally block... //[ /wattage/wtgMainMenu.jsp;
              Line: 37]
                   if (_western_common_jsptag_HeaderTag_0 != null) westerncommon_jsptag_HeaderTag_0.release();
              //[ /wattage/wtgMainMenu.jsp; Line: 37]
              } //[ /wattage/wtgMainMenu.jsp; Line: 37]
              ----------CONSOLE OUTPUT-------------
              Getting Page permissions for page: wtgMainMenu.jsp user: 0
              Page Permissions: Insert-1 View-1 Update-1 Delete-1
              HeaderTag -- Constructing
              Thu Apr 05 11:19:00 CDT 2001:<E> <ServletContext-General> exception raised on
              wattage/wtgMainMenu.jsp'
              javax.servlet.ServletException: runtime failure in custom tag 'HeaderTag'
              at jsp_servlet.wattage.wtgmainmenu._jspService(wtgmainmenu.java:398)
              at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
              at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
              pl.java:124)
              at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
              textImpl.java:744)
              at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
              textImpl.java:692)
              at weblogic.servlet.internal.ServletContextManager.invokeServlet(Servlet
              ContextManager.java:251)
              at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.jav
              a:363)
              at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:263)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              

    I just started getting this error after a year in production environment without any problems. Did you every find out what caused this or better yet how to prevent this?
              Dan.
              

  • How can I use evaluate to get the instance variable in customized tag

    1.
    At first , I create a class called bean,and declared several params in it and do not define any getter function for the param.
    class bean{
    String param = "test";
    SomeClass scObj = new SomeClass();
    2.
    The second ,I use
    request.setAttribute("beanObj",new bean());
    3.
    And then I wanna use the customized tag to show a text box , then initialize it's value.
    <salt:text name="param" value="beanObj.param">
    <salt:text name="obj" value="beanObj.scObj.func()">
    4.
    I tried the evaluator provided by JexlContext ,Struts, JSTL and it seems that if I do not define the getter for the variable ,I can not get the bean's instance variable's value.
    Expression e = ExpressionFactory.createExpression( value );
    JexlContext jc = JexlHelper.createContext();
    jc.getVars().put(strInitBeanName, request.getAttribute("beanObj"));
    Object obj = e.evaluate(jc);
    the result of the obj is null....
    Can anybody recommand some other evaluator can get the value of a instance variable from an object?

    do you have any other suggestion ? Nops, somebody else may have though. AFAIK, all lookups of the type
    beanName.propertyNameuse reflection on the getXXX() methods to access the property.
    Having said that, I guess you could write one though in a custom tag, using the same - reflection (you will ahve to rely on the java.lang.reflect.Field class quite heavily) - but that would be reinventing the wheel for most other functionality that you would have to include (like looking up the bean in scope etc)
    cheers,
    ram.

  • Custom Tag in race condition with OC4J v9.0.2.0.0...

    Hello all,
    (I tried deploying my application with OC4J 9.0.3 but none of my existing
    tags worked)
    I developed a OC4J web application implementing my own tag library extension
    and found out that there was occurring a race condition to the fact that two
    users (different sessions) where accessing the same
    tag at the same time. In the offending tag implementation I only have
    instance members and not static which could also cause a
    concurrent access problem.
    I found that OC4J was reusing concurrently the same
    Tag instance when it should not do that!!!
    public class pagesIteratorTag extends BodyTagSupport {
    // only instance class members...
    public void doInitBody() throws JspException {
    System.out.println("pageSetIteratorTag::doInitBody - Tag instance value: " + this.toString() + " for user: " + this.pageContext.getSession().getAttribute("j_username"));
    public int doAfterBody() throws JspException {           
    System.out.println("pageSetIteratorTag::doAfterBody - Tag instance value: " + this.toString() + " for user: " + this.pageContext.getSession().getAttribute("j_username"));
    Note the pagesIteratorTag@2e same instance is used when it should not
    1 because the tag instance should be protected from multiple concurrent
    access even though it can be pooled and reused if it is free.
    pageSetIteratorTag::doInitBody - Tag instance value: com.kdlabs.fogal.tagext.pagesIteratorTag@2e for user: Frank
    pageSetIteratorTag::doAfterBody - Tag instance value: com.kdlabs.fogal.tagext.pagesIteratorTag@2e for user: Frank
    pageSetIteratorTag::doInitBody - Tag instance value: com.kdlabs.fogal.tagext.pagesIteratorTag@2e for user: Giovanni
    pageSetIteratorTag::doAfterBody - Tag instance value: com.kdlabs.fogal.tagext.pagesIteratorTag@2e for user: Giovanni
    pageSetIteratorTag::doInitBody - Tag instance value: com.kdlabs.fogal.tagext.pagesIteratorTag@2e for user: Giovanni
    pageSetIteratorTag::doAfterBody - Tag instance value: com.kdlabs.fogal.tagext.pagesIteratorTag@2e for user: Giovanni
    Session for user Frank throws a null pointer exception because Giovanni's session
    started accessing the variable.
    Can anyone advise please?
    Best Regards,
    Giovanni

    First of all, you said none of your tags worked in 9.0.3. What happened? Did you do any debugging of the problem?
    Comparing the "toString()" output of your tag does not guarantee they are the same instance. That is just the output of "hashcode()", not the "pointer" to the object. The hashcode is generated from the contents of the object, not its "identity".
    I suggest you track the NPE in the debugger and get more information before you assume the container is at fault (which is still an outside possibility). SDK API Javadoc
    Object class:
    The general contract of hashCode is:
    1-. Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
    So, the toString() is properly returning the suffix of the object instance
    number unique for that instance and is then being reused by OC4J even though
    it is being accessed from another session thread, that must not happen and it
    is not compliant with the JSP spec.
    The other history is that when I implemented my custom tags OC4J was JSP 1.1 compliant
    and not 1.2, so after moving to 1.2 the scripting variables can be defined in XML and
    by subclassing TagInfo class, the last option doesn't work with OC4J 9.0.3, not good...
    Thanks for your help,
    I will keep trying to figure out what the problem migth be,
    Best Regards,
    Giovanni

  • Custom Tag attribute

    Hi folks,
    I am trying to create a custom tag that accepts a java.util.Locale as a parameter, and for some reason the container is giving me all kinds of attitude. Here's the detail:
    ----from the .tld---
    <tag>
           <name>loadMasthead</name>
           <tag-class>uiTagHandlers.LoadMasthead</tag-class>
           <body-content>empty</body-content>
           <description>Paints the masthead for a given page</description>      
           <attribute>
                <name>locale</name>
                <required>false</required>
                <rtexprvalue>true</rtexprvalue>
             <type>java.util.Locale</type>
           </attribute>
      </tag> ---end tld--
    from the jsp-
    <%@ taglib uri="/WEB-INF/simpleUITags.tld" prefix="helper" %>
    <%@ page import="java.util.Locale" %>
    <helper:loadMasthead locale="<%= Locale.US %>" />---end jsp----
    ---from the handler-----
         public int doTagStart() throws JspTagException{
              JspWriter out = pageContext.getOut();
              try{
                   if( locale != null)          
                        out.print( UIHelper.loadMasthead(locale) );
                   else
                        out.print( UIHelper.loadMasthead() );
              }catch( Exception ex ){
                   throw new JspTagException( ex.getMessage() );
         return SKIP_BODY;
         public int doTagEnd() throws JspTagException{
         return SKIP_PAGE;
          * Sets the locale.
          * @param locale The locale to set
         public void setLocale(java.util.Locale locale) {
              this.locale = locale;
    end handler---
    Here's the error I'm getting from the container:
    [8/5/04 12:14:34:704 EDT] 7abbd628 WebGroup E SRVE0026E: [Servlet Error]-[Unable to convert string '<%= Locale.US %>' to class java.util.Locale for attribute locale: java.lang.IllegalArgumentException: Property Editor not registered with the PropertyEditorManager]: org.apache.jasper.JasperException: Unable to convert string '<%= Locale.US %>' to class java.util.Locale for attribute locale: java.lang.IllegalArgumentException: Property Editor not registered with the PropertyEditorManager
         at org.apache.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager(JspRuntimeLibrary.java:920)
         at org.apache.jsp._index._jspService(_index.java:84)
         at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
    Any ideas what is going on here?
    Thanks in advance,
    Matt

    The taglib always passes a string. The container is supposed to change it to the proper object, but some do not, as it wasn't clear in the original specs (I found various bug reports). My container does not do this properly for taglibs, so I ended up using a bean, which it processed correctly.
    Your container can't figure out how to change the String it receives to the Locale object it's supposed to set the property to.
    I found a similar problem displayed here:
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4727371
    You'd need to check with your container docs to see if yours is supposed to be able to do the conversion. If not, you'll either need to write it yourself or do what I did and use a bean so it never passes a string to begin with.

  • Custom tag with struts

    Hi
    I would like to create a custom tag that will print this section of html with struts:<tr>
         <td class="f_name"><bean:message bundle="fields" key="firstName" /></td>
         <td class="f_value"><html:text property="firstName" /></td>
    </tr>This means that i sould pass to the custom tag the folowing attributes:
    1. bundle - the bundle name to use ("fields").
    2. property - the name of the submitted filed and the key in the bundle resource ("firstName").
    This is how i want to use it:<html:form action="/register.do" enctype="UTF-8">
    <table cellspacing="0" cellpadding="0" border="0" class="t_details">
    <mytld:text bundle="fields" key="firstName"/>
    <mytld:text bundle="fields" key="lastName"/>
    </html:form>For me, this way looks much easier to develop my application/s, don't you agree?
    The problem is that i can't (or i don't know how) to use custom tags in other a custom tag, and if i include a jsp file (with pageContext.indlude("url");), how do i pass the attributes to the jsp page?
    Thanks a lot
    mamtz

    Interesting answer, i'll put it in my mind, but this is not what i ment :) (nice thinking...)
    what i ment was, html:text tag has many attributes like: property, name, alt, size, maxLength and so on...
    i would like sometimes to use size or maxLength and sometimes not.
    take a look at what i wrote:<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%
         String property=""+request.getAttribute("property");
         String bundle=""+request.getAttribute("bundle");
         Object max=request.getAttribute("maxLength");
         String maxLength= max==null ? "" : ""+max;
         Object s=request.getAttribute("size");
         String size= s==null ? "" : ""+s;
    %>
         <tr>
              <td class="f_name"><bean:message bundle="<%=bundle%>" key="<%=property%>" /></td>
    <%     if(max!=null && s!=null){
    %>          <td class="f_value"><html:text property="<%=property%>" maxlength="<%=maxLength%>" size="<%=size%>" /></td>
    <%     }else if(max!=null){
    %>          <td class="f_value"><html:text property="<%=property%>" maxlength="<%=maxLength%>" /></td>
    <%     }else if(s!=null){
    %>          <td class="f_value"><html:text property="<%=property%>" size="<%=size%>" /></td>
    <%     }else{
    %>          <td class="f_value"><html:text property="<%=property%>" /></td>
    <%     }
    %>     </tr>pretty complicated, is'nt it?
    think what would happen if i would like to add just one more attribute...

  • Parsing EL expression in custom tag 10.1.3.4

    Hello all,
    I have a custom tag that extends CoreOutputTextTag. This tag needs to resolve the El expression passed in from the value attribute and perform an operation with it. Since I this tag needs to work with adf 10.1.3.4, the jsp level is 1.2 and does not support container parsing of EL expression directly in the page ($).
    I have tried a couple approaches but both of them result in just the same EL expression I pass in being returned to me. Anyone have an idea of the proper way to resolve an EL expression within a custom tag?
    Thanks in advance,
    - Joe
    public class CoreOutputTextTag extends oracle.adfinternal.view.faces.taglib.core.output.CoreOutputTextTag {
        private String groupId;
        private String groupCode;
        private String value;
        public void setValue(String value) {
            this.value = value;
            super.setValue(value);
        public int doStartTag() throws JspException {
            super.doStartTag();
            UIComponent uiComponent = this.getComponentInstance();
            if (uiComponent instanceof CoreOutputText) {
                CoreOutputText coreOutputTextComponent =
                    (CoreOutputText)uiComponent;
                if (coreOutputTextComponent.getValue() == null) {
                    String codeValue =
                        (String)ExpressionEvaluatorManager.evaluate("value", value,
                                                                    java.lang.String.class,
                                                                    this,
                                                                    pageContext); // the page context
                    try {
                        ExpressionEvaluator expressionEvaluator =
                            pageContext.getExpressionEvaluator();
                        codeValue =
                                (String)expressionEvaluator.evaluate(value, java.lang.String.class,
                                                                     pageContext.getVariableResolver(),
                                                                     null);
                    } catch (ELException elex) {
                    SystemSettingRow row =
                        SystemSettings.getSystemSettings(groupId, groupCode, null,
                                                         value);
                    if (row != null)
                        coreOutputTextComponent.setValue(row.getShortDesc());
            return TagSupport.SKIP_BODY;
        public void setGroupId(String groupId) {
            this.groupId = groupId;
        public String getGroupId() {
            return groupId;
        public void setGroupCode(String groupCode) {
            this.groupCode = groupCode;
        public String getGroupCode() {
            return groupCode;
    <tag>
      <name>coreOutputText</name>
      <tag-class>od.adf.ics.ui.taglib.CoreOutputTextTag</tag-class>
      <body-content>empty</body-content>
      <attribute>
       <name>groupId</name>
       <required>true</required>
      </attribute>
      <attribute>
       <name>groupCode</name>
       <required>true</required>
      </attribute>
      <attribute>
       <name>id</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>truncateAt</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>description</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>escape</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>shortDesc</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>partialTriggers</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>onclick</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>ondblclick</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>onmousedown</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>onmouseup</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>onmouseover</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>onmousemove</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>onmouseout</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>onkeypress</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>onkeydown</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>onkeyup</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>styleClass</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>inlineStyle</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>value</name>
       <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
       <name>converter</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>rendered</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>binding</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
      <attribute>
       <name>attributeChangeListener</name>
       <rtexprvalue>false</rtexprvalue>
      </attribute>
    </tag>

    I also would like to know how to accomplish this. I have a similar requirement and need to set the "disable" attribute on a commandbutton and requires an el statement that calls a methodAction defined on the pageDef.
    I followed the great instructions over on this thread:
    ADF FACES:Creating custom component on top of adf
    on how to create custom adf tags for JDeveloper 10.1.3.4.
    many thanks!
    Wes
    Edited by: Wes Fang on Sep 16, 2010 5:39 AM

Maybe you are looking for

  • Runtime Error in Portal

    Hi All, In one of my iviews, i need to set an input filed as of Pull Down type. Now there are 2 options available either to set the input field as a Dropdown or as a Pull down. When i use Dropdown its working absolutely fine, but when i change it to

  • MBAM 2.5 Accounts and Groups

    Hi, i´m a bit confused by the required accounts for mbam 2.5. from TechNet: DB Accounts / Groups: Compliance and Audit Database read-only user or group for reports User or Group Read-only access domain user or group Name of the user or group that wil

  • EP Upgrade with Custom Developments 2

    Hi all, I am planning to upgrade EP 6.0 to EP 7.0 Currently, some java standard application (for example: leave application [esslea~sap.com] already have  been modified in order to fullfill my user requirement . Once we have upgrade to the EP 7.0, is

  • Dynamic list and thumb loops

    hello I try to create a dynamique list with thums loops associates (to describe a stuff to sell) and it work fine when I select from a list (URL parametre) But I would like to navigate in my detail page (with the loop thumb) whit the next or last lin

  • Camera flash on e63 also wlan connectivity

    Can anyone help - I just got a re-conditioned E63 and when flash is needed in dark conditions all I get is a blue image on screen! Tried night mode on/off and white balance - doesn't make any difference. Just a general query - am totally new to Wlan