Use jsp tag output as another tag's attribute value

I don't know anyone has ever tried this, one tag's attribute value needs to be dynamically set using another tag's output. Something like
<layout:grid cols="<layout:write name="element" property="value"/>'' space='false'>
</layout:grid>
I want the cols attribute of grid tag to be the output of <layout:write name="element" property="value"/>
The way I wrote is of course not working.
But I know PHP can do things similar to this, JSP should be able to achieve something like this too.
If anyone knows how to do this or using any alternative way to do this, please let me know.
Shane

something like this...
          OuterTag qParent = null;
          try {
                    Tag myParent = getParent();
                    while (myParent != null ) {
                      // loop up through tags until you find the one you want
                         if (myParent instanceof OuterTag) {
                              qParent = (OuterTag) myParent;
                              data = qParent.getSomeData();
                         } else {
                              myParent = myParent.getParent();
               }

Similar Messages

  • Using JSP scriplets in the JSF tags

    Hi,
    I haven't done that much JSP development using various tag libraries prior to looking at JSF, hence this very basic question:
    I am declaring and manipulating Java variables in my JSP. Is there a way to access those in my JSF tags? It seems that something like:
    <%
    String myString="MyLabel";
    %>
    <h:view>
    <h:outputText id="myID" value="<%=myString%>" />
    </h:view>
    blows up in the JSF processor.
    I am porting some stuff to JSF and hence do not use backing beans in all cases.
    Any suggestions/ideas/pointers are greatly appreciated.
    Thanks in advance,
    Vadim.

    JSF action element attributes take JSF EL expressions, not Java expressions. A JSF EL expression has access to objects in one of request, session or application scope only, not to scripting variables. One way to get your example to work is by putting the String in one of these scopes within the scriptlet, e.g.:
    <%
      String myString="MyLabel";
      request.setAttribute("myString", myString);
    %>
    <h:view>
      <h:outputText id="myID" value="#{myString}" />
    </h:view>But, if you're porting a JSP-based application to JSF, I strongly recommend that you move all scriptlet code into beans; otherwise it's kind of pointless to migrate to JSF. The strength of JSF is its separation of UI layout and application logic.
    Even though JSP happens to be one way to wire up a JSF view with JSF components, JSF has very little to do with JSP. You need to understand the basic JSF component model, event-driven development, and use JavaBeans to really gain any benefits. Don't be fooled into believing that JSF is "just a new JSP tag library" by the support for JSP as the default presentation layer; it's far more than that, and I personally believe that using JSP as the presentation layer makes using JSF a lot harder than it should be. In fact, most of the issues posted in this forum are issues with the JSP layer, not with the core JSF components or the infrastructure classes.
    Hans Bergsten (EG member)

  • In Jsp TagLib how can I get the Attribute value (like JavaBean) in jsp

    Dear Friends,
    TagLib how can I get the Attribute value (like JavaBean) in jsp .
    I do this thing.
    public void setPageContext(PageContext p) {
              pc = p;
    pc.setAttribute("id", new String("1") );
              pc.setAttribute("first_name",new String("Siddharth")); //,pc.SESSION_SCOPE);
              pc.setAttribute("last_name", new String("singh"));
    but in Jsp
    <td>
    <%=pageContext.getAttribute("first_name"); %>
    cause null is returing.
    Pls HELP me
    with regards
    Siddharth Singh

    First, there is no need to pass in the page context to the tag. It already is present. How you get to it depends on what type of tag:
    Using [url http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/jsp/tagext/SimpleTagSupport.html]SimpleTagSupport
    public class MyTag extends SimpleTagSupport
      public void doTag()
        PageContext pc = (PageContext)getJspContext();
        pc.setAttribute("first_name", "Siddharth");
        pc.setAttribute("last_name", "Singh");
        pc.setAttribute("id", "1");
    }Using [url http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/jsp/tagext/TagSupport.html]TagSupport or it's subclass [url http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/jsp/tagext/BodyTagSupport.html]BodyTagSupport the page context is aleady declared as an implicit object:
    public class MyTag extends TagSupport
      public void doStartTag()
        pageContext.setAttribute("first_name", "Siddharth");
        pageContext.setAttribute("last_name", "Singh");
        pageContext.setAttribute("id", "1");
    }In each case, this sort of thing should work:
    <mytags:MyTag />
    <%= pageContext.getAttribute("first_name") %>I

  • How to retrieve attribute value from my JSP?

    My servlet needs to redirect to a JSP. Before that, I set an attribute value.
    getServletContext().setAttribute("filename",templateFile);
    RequestDispatcher rd = getServletContext().getRequest...
    rd.forward(request, response);
    In my JSP, this is how I want to retrieve it:
    <%
    String filename = (String)request.getAttribute("filename");
    if (filename != null)
    %>
    <%= filename %>
    <%
    else
    %>
    it is null
    <%
    %>
    But the value is always null? Do I need any tag or declaration on the top of my JSP?

    Can i set attribute for list and get that list using request.getAttribute() in jsp?
    ex.
    in action
    List plist;
    plist = ...
    request.setAttribute("plist", plist);
    to get this value in jsp
    <%
    List plist = (List)request.getAttribute("plist");
    %>
    is this code is allowed?

  • Using a custom tag inside another tag's attribute value?

    Hi all,
    I have a custom tag, mytag:link, whose use currently looks like this:<mytag:link path="/images/logo.gif"/>Nevermind what the tag does. Here's its TLD:<?xml version="1.0" encoding="ISO-8859-1" ?>
    <!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.1.1</tlib-version>
        <jsp-version>1.2</jsp-version>
        <short-name>My custom tags TLD</short-name>
        <tag>
            <name>link</name>
            <tag-class>test.MyLinkTag</tag-class>
            <body-content>empty</body-content>
            <description>...</description>
            <attribute>
                <name>path</name>
                <required>true</required>
                <rtexprvalue>true</rtexprvalue>
            </attribute>
        </tag>
    </taglib>I want to replace the path argument of the mytag:link tag to the result of the evaluation of another tag (a SiteMesh decorator tag) like this:<mytag:link path="<decorator:getProperty property="meta.logo"/>"/>This, of course, doesn't work, as I get the following error:org.apache.jasper.JasperException: /decorator.jsp(34,92) equal symbol expected
         org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
         org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
         org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:86)
         org.apache.jasper.compiler.Parser.parseAttribute(Parser.java:193)
         org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:143)
         org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1328)
         org.apache.jasper.compiler.Parser.parseElements(Parser.java:1564)
         org.apache.jasper.compiler.Parser.parse(Parser.java:126)
         org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
         org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
         org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:146)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         com.opensymphony.module.sitemesh.filter.PageFilter.applyDecorator(PageFilter.java:156)
         com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:59) If I replace the call to the other tag with
    <mytag:link path="<%=someVariable%>"/>then it all works fine. This behavior seems correct, as the SiteMesh getProperty tag is writing its output to the Writer returned by pageContext.getOut() as it should. As such, this seems to be a design question, then. How are you supposed to do this?
    Thanks in advance,
    Matthew

    Note that I've also posted a question to the SiteMesh user forums about this. It has more information about the motivation of this question.
    See http://forums.opensymphony.com/thread.jspa?threadID=8561
    I'm still looking for an answer, though.
    --matthew                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Error when run a simple sample using jsp tag

    When i run a jsp using jsp tag, the tomcat gave me the following information:
    Resolve entity failed-//Sun Microsystems,Inc.//DTD JSP Tag Library 1.2//EN http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd
    My tld file is:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!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>sample</short-name>
    <uri>WEB-INF/sampleTag</uri>
    <display-name>SampleTag</display-name>
    <description>Sample TLD</description>
    <tag>
    <name>time</name>
    <tag-class>com.sample.taglib.TimeTag</tag-class>
    <body-content>empty</body-content>
    </tag>
    </taglib>
    Anybody can tell me why?
    Thanks!!!

    It's strange bacause DTD is available under given address.
    Which JSP version are you using?
    Do you have any other tld file, which uses the same DTD version? Do tags define in it work properly?
    Maby try to use 1.1 version of DTD?
    <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">But remember than version 1.1 has another node names (see http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd).

  • Using JSP declaration tags and expression tags

    I am trying to use JSP without embedding any business logic into my view pages.
    I know that its not good practice to use scriptlets in pages, but is it ok to declare variables and then reference them with expression tags?
    And on another note does anybody have any links to any decent jsp tutorials (I am not asking for a link to google here, or a link to a google search), by decent I mean tutorials that are not outdated and use scriptlet tags as I am trying to egt away from this.
    Thanks

    PaulOckleford wrote:
    I am trying to use JSP without embedding any business logic into my view pages.
    I know that its not good practice to use scriptlets in pages, but is it ok to declare variables and then reference them with expression tags?You can use the JSTL <c:set> for that. But I would still prefer the Servlet above that.
    And on another note does anybody have any links to any decent jsp tutorials (I am not asking for a link to google here, or a link to a google search), by decent I mean tutorials that are not outdated and use scriptlet tags as I am trying to egt away from this.You can find here at least one: [http://balusc.blogspot.com/2008/07/dao-tutorial-use-in-jspservlet.html].

  • Escaping tag output for use in XHTML document?

    I'm converting a JSP page from HTML to XHTML, and have run across a problem with tags outputting XHTML-invalid characters (&'s and <'s). For example:
    <form action="<f:postResults />">
    postResult returns a string with those invalid characters, and so far I've been unable to figure out how to work around that. Any ideas?

    Our print publications are created in InDesign CS5 for Mac then the text is exported to RTF files then sent to an outside company to be converted to our XML specifications for use by our website developers.  I would like to create a workflow in which our XML tags are included in the InDesign layouts and then export the XML from the layouts.
    Some more detail about what kind of formatting is necessary might be helpful.
    I know that IDML files contain the entire layout in XML format.  Is it a good idea to extract what we need from IDML, using the already-assigned tags?
    Well, if you want to export the whole document, it's the only reasonable approach.
    We use a workflow system such that each story is a seperate InCopy document, stored in ICML format (Basically a subset of IDML). Our web automation uses XSLT to convert each story into HTML for use on our web site; it also matches it up with external metadata so it knows what is a headline and what is not, etc.. It is not exactly hassle free, and every once in a while someone uses a new InDesign feature that breaks things (e.g., our XSLT has no support for paragraph numbering, so numbered paragraphs show up without their numbers).
    You could do the same thing with with IDML, you'd just have to pick out each story, but that's small potatoes compared to all the XSL work you're going to have to do.
    On the other hand, there may be better approaches if you're not going to export the whole document. For instance,  you could use scripting to export each story as an RTF file, and then you could convert the RTF files into HTML using other tools.

  • How to get the values of an Array using JSP Tags

    Hey guys,
    I need some help. I've splited a String using
    fn:split(String, delim) where String = "1,2,3,4" and delim is ,
    This method returns an Array of splited Strings. how do i get the values from this array using jsp tags. I don't wanna put java code to achive that.
    Any help would be highly appreciated
    Thanks

    The JSTL forEach tag.
    In fact if all you want to do is iterate over the comma separated list, the forEach tag supports that without having to use the split function.
    <c:set var="list" value="1,2,3,4"/>
    <c:forEach var="num" items="${list}">
      <c:out value="${num}"/>
    </c:forEach>The c:forTokens method will let you do this with delimiters other than a comma, but the forEach tag works well just with the comma-delimited string.

  • How to use JSP custom tag lib in PAR file?

    Hi All,
    I am trying to customize mastheaderpar file. For that I have downloaded relevant par file and making the changes accordingly.
    As part of the changes I would require to use JSP custom tag library in my par file.
    I have the TLD file and relevant classes in the jar file. I would like to know where and what kind of modifications have to be done to use the jsp custom tag library.
    I tried modifying some things in portalapp.xml but was not successful.
    Please help me on how to proceed with this? It would be great if you can provide the xml entry to use this tag library
    Thanks
    Santhosh

    Hi Johny,
    Thanks for the reply. Actually I am able to change colors etc. with out any problem.
    My requirement is to use XMLTaglib in mastheader par file. This tag lib is from apache tomcat. I have the relevant TLD and class files. I copied TLD file into taglib dir of portal-inf and class file in src api.
    And I have added the following line in portalapp.xml under component-profile section of default
    <property name="tlxtag" value="/SERVICE/Newmastheader/taglib/taglibs-xtags.tld">
    Is this the right way to use tag lib? Actually before adding this line I used to get the error saying "Error parsing taglib", but now the error does not occur and I am getting new error. This is an exception in one of the taglib classes.
    Could any one provide me some inputs on how to check this error?
    Thanks
    Santhosh

  • Problem using jsp:include from inside a custom tag

    Hi, All !
              I have a problem using <jsp:include> from inside a custom tag. Exception is:
              "java.lang.ClassCastException: weblogic.servlet.jsp.BodyContentImpl"
              Apparently, weblogic tries to cast BodyContentImpl to JspWriterImpl and
              could not do this. Is it a bug, since in the 1.1 spec is said: "The
              BodyContent is a subclass of JspWriter that can be used to process body
              evaluations so they can retrieved later on."
              My code is:
              <wfmklist:items>
              <jsp:include page="item.jsp" flush="true"/>
              </wfmklist:items>
              

    This is an area of contention with WL. It is not so tolerant with regards to
              the spec. I spent several days recently trying to convince it to accept the
              specification in regards to bodies and includes and it appears to have
              successfully rebuffed my efforts.
              Frankly, this is very disappointing. It appears that some shortcuts were
              taken on the way to JSP 1.1 support, and the result is a very hard-coded,
              inflexible implementation. As I have not seen the implementation myself, I
              hate to assume this, however one could posit that the term "interface" was a
              foreign concept during the implementation, other than as some annoying
              intermediary reference requiring an immediate cast to a specific Weblogic
              class, which in turn is apparently required to be final or have many final
              methods, as if being optimized for a JDK 1.02 JIT.
              I am sorry that I don't have any positive suggestions other than to use a
              URL object to come back in an execute the necessary "include" directly. You
              lose all context (other than session) and that can cause its own problems.
              However, you can generally get the URL approach to work, and you will
              hopefully avoid further frustration.
              Peace,
              Cameron Purdy
              Tangosol, Inc.
              http://www.tangosol.com
              Tangosol: How Weblogic applications are customized
              "Denis" <[email protected]> wrote in message
              news:[email protected]...
              > Hi, All !
              > I have a problem using <jsp:include> from inside a custom tag. Exception
              is:
              > "java.lang.ClassCastException: weblogic.servlet.jsp.BodyContentImpl"
              >
              > Apparently, weblogic tries to cast BodyContentImpl to JspWriterImpl and
              > could not do this. Is it a bug, since in the 1.1 spec is said: "The
              > BodyContent is a subclass of JspWriter that can be used to process body
              > evaluations so they can retrieved later on."
              >
              > My code is:
              > ...
              > <wfmklist:items>
              > <jsp:include page="item.jsp" flush="true"/>
              > </wfmklist:items>
              > ...
              

  • Unable to use jsp:useBean tag

    when I use
    <jsp:useBean id="addressBean" class="AddressBean" scope="session"/>
    I get the following error
    Exception Details: org.apache.jasper.JasperException
    Unable to compile class for JSP No Java compiler was found to compile the generated source for the JSP. This can usually be solved by copying manually $JAVA_HOME/lib/tools.jar from the JDK to the common/lib directory of the Tomcat server, followed by a Tomcat restart. If using an alternate Java compiler, please check its installation and access path.
    So my question is how to use the <jsp:useBean> tag in JSC

    Please see my message How to set developer's mode for oracle jsp engine.
    As a very early warning of the future, this way of setting configuration paramemter in web.xml for oracle jsp engine will be deprecated in the next major version of oc4j and desupported probably later on. Yes, it is still supported in 10.1.3 and the next major version, though.

  • Why does people use JSP Tag for their JSP page? (Urgent)

    I don't know what benifit if I am using JSP Tag.
    If anyone knows, pls give me an idea and the advantage of using JSP Tag in JSP Page!
    Thanks in advance!

    You have to read a little about JSP, JSP stands for JavaServer Pages, you can use jsp tags and you can use java code. If you dont want to use jsp tags then you should just write html file, if you just want to use java, then write java class or a servlet.
    The need for jsp arised because people were inserting html code inside a servlet class..a big no no..and a headache. JSP separate model from the view...read a little about MVC-2 model view controller pattern.
    Also read some tutorial on this website...good luck
    K

  • I can't use JSP tags lib in IWS6

    I was trying to use JSP tags lib but the web server doesn't find the *.tld file. Some messages are shown:
    25/Jun/2002:19:40:28] info ( 5604): JSP: JSP1x compiler threw exception
    org.apache.jasper.compiler.CompileException: /local/iplanet/docs/menu_principal.jsp(1,0) Unable to open taglibrary http://apache.org/taglibs/dbtags : Could not locate TLD http://apache.org/taglibs/dbtags
    at org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEventListener.java:707)
    at org.apache.jasper.compiler.DelegatingListener.handleDirective(DelegatingListener.java:110)
    at org.apache.jasper.compiler.Parser$Directive.accept(Parser.java:215)
    at org.apache.jasper.compiler.Parser.parse(Parser.java:1077)
    at org.apache.jasper.compiler.Parser.parse(Parser.java:1042)
    at org.apache.jasper.compiler.Parser.parse(Parser.java:1038)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:218)
    at com.iplanet.server.http.servlet.NSServletEntity.load(NSServletEntity.java:252)
    at com.iplanet.server.http.servlet.NSServletEntity.update(NSServletEntity.java:173)
    at com.iplanet.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:416)
    [25/Jun/2002:19:40:28] warning ( 5604): Internal error: Failed to get GenericServlet. (uri=/menu_principal.jsp,SCRIPT_NAME=/menu_principal.jsp)
    I have some doubts about how to work with JSP Tags in iws6. What should I do to get this work?
    The tag lib is gotten from jakarta project and I'd like to know which steps i have to follow.
    Thank you very much

    Hi,
    What you have to do is this:
    - Include the jar file in the WEB-INF/lib
    - Include the tld file in a directory under WEB-INF, for example tlds
    - Create a mapping in the deployment descriptor (web.xml), to make the taglib available, something like this:
    <taglib>
    <taglib-uri>http://jakarta.apache.org/taglibs/io</taglib-uri>
    <taglib-location>/WEB-INF/tlds/io.tld</taglib-location>
    </taglib>
    Then in the jsp, you have to invoke it like this:
    <%@ taglib uri="http://jakarta.apache.org/taglibs/io" prefix="io" %>
    <io:http url="http://mustang:4004/NASApp/fortune/fortune" action="GET"/>
    Hope this helps
    Juan

  • USE jsp TAG

    How do I use JSP tag with Weblogic?
              Where should I put my tld file, and where should I put the Java class file?
              I put the Java files under
              C:\bea\wlserver6.0sp1\config\mydomain\applications\DefaultWebApp_myserver\WE
              B-INF\lib and it was not successful.
              Thank you
              

    something like this...
              OuterTag qParent = null;
              try {
                        Tag myParent = getParent();
                        while (myParent != null ) {
                          // loop up through tags until you find the one you want
                             if (myParent instanceof OuterTag) {
                                  qParent = (OuterTag) myParent;
                                  data = qParent.getSomeData();
                             } else {
                                  myParent = myParent.getParent();
                   }

Maybe you are looking for

  • Bridge will not start.

    Hi all, I have Adobe Bridge CS3, Windows Vista ultimate 32bit. When I start bridge from the desktop shortcut, or in the programs folder I get this error message "The procedure entry point sqlite3_prepare_v2 could not be located in the dynamiclink lib

  • Burning to disc from DVR

    is it possible? i saw there was a tivo software from roxio i belive. i was wondering if i'd be able to plug my DVR into my macbook to import stuff to burn to disc. the DVR has an output to go to a DVD recorded, but i don't want to buy one if i can do

  • When I try to upgrade the ios software on my ipod touch 4 g flashes Apple . Heip me please!

    when I try to upgrade the ios software on my ipod touch 4 g flashes Apple . Heip me please!

  • ISE integration with SMS gateway required license

    Hello All, We have cisco WLC with guest wireless access configured to use local database. the managment requires new solution to send cridintials to user throug SMS after the user signup through portal. we decided to use the cisco ISE. my question is

  • Error When Installing Cisco ICM Maintenance Release 8.5(4)

    Hi,  I've successfully installing ICM 8.0(1a), My environment is Windows Server 2008 R2 Enterprise, Service Pack 1 x64. Now I'm trying to install Cisco ICM Maintenance Release 8.5(4), but the error occurs, the log is : 2014-09-03 14:09:27 [Informatio