JSP attributes

What are the attributes of JSP?.This is the question asked to my friend in an interview.Please give the answer in detail.And the links where we can the complete solutions for problems like this

or he could have been a non technical manager that thought he was asking a good questions but was really making himself look like an idiot :)
but probably not.... They usually wait until after you accept the job and start working for them before they reveal things like that.

Similar Messages

  • BUG JSP editor jsp:attribute action

    Hello, there's a bug in JDeveloper.
    1. Create tag file
    <%@ tag pageEncoding="UTF-8"%>
    <%@ attribute name="x" fragment="true" required="true" %>
    2. Create JSP file
    <%@ page contentType="text/html;charset=UTF-8"%>
    <%@ taglib tagdir="/WEB-INF/tags/" prefix="tags"%>
    <tags:tagFile1>
    <jsp:attribute name="x">
    Hello
    </jsp:attribute>
    </tags:tagFile1>
    JDeveloper underlines the tag in red and says "Required attribute x is missing..." OC4J runtime behaviour is normal (if we ignore other issues with tag files). I am using JDeveloper 10.1.3.1.

    Hi,
    Put this code in the editor and see it will show you the preview
    =========================================
    <%@ taglib uri="tagLib" prefix="hbj" %>
    <html>
    <body>
    Hello
    </body>
    </html>
    ============================================
    This will not show you a preview
    ===========================================
    <%@ taglib uri="tagLib" prefix="hbj" %>
    <jsp:useBean id="myBean" scope="application" class="com.cts.bean.User" />
    <hbj:content
         id="myContext">
    <hbj:page title="Kirupanand">
       <hbj:form id="myFormId" >
      <hbj:inputField type="String"  id="Getuser"
        size="30"  value="" maxlength="8"
        disabled="false">
       </hbj:inputField>
    <hbj:inputField  type="String"
    id="Displayuser"  size="30"
    value="<%=myBean.getUser()%>"
    maxlength="8"      disabled="false">
    </hbj:inputField>
    <hbj:button  id="Store"  text="Save"  width="125px"
    tooltip="Save User Name"  onClick="clientSave"
    disabled="false" design="STANDARD" />     
      </hbj:form>
    </hbj:page>
      </hbj:content>
    <html>
    <body>
    Hello
    </body>
    </html>
    ===================================================
    what does this mean? If you use HTMLB tags then you cannot see a preview. Not because of " <%@ taglib uri="tagLib" prefix="hbj" %> " this statement is used to tell to the program which executes the jsp that use this TagLib to understand what the component starting with hbj should do.

  • JSP - Attribute "style" was already specified for element "html:text".".

    I´m using Weblogic 10 and one of my pages is throwing that exception, what´s wrong? I´m migrating from Weblogic 8.2 to Weblogic 10!
    updateCustomer.jsp:1:1: The page failed validation from validator: "org.xml.sax.SAXParseException: Attribute "style" was already specified for element "html:text".".
    <%@ page contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %>
    ^--------------------------------------------------------------------------------^
         at weblogic.servlet.jsp.JavelinxJSPStub.compilePage(JavelinxJSPStub.java:296)
         at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:200)
         at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:164)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:235)
         at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:391)
         Truncated. see log file for complete stacktrace

    Check your "html:text" elements. One of them has duplicate attribute "style"

  • How to Get Portlet Namespace in a JSP attribute

    Hi All,
    The id of any component in a JSF application (with JSR168 portlets) takes the form
    'view'+'<portlet:namespace/>'+':'+'formname:componentidname';
    I need this id to be used for certain validations.
    Currently I am using it as below :-
    <h:intputText required="#{ ! empty param['viewns_7_CGAH47L000NAF0I04I42ND10P7_:form:login']}"/>
    Presently I have hardcoded the portlet namespace 'ns_7_CGAH47L000NAF0I04I42ND10P7_' by looking into the html source of the rendered page.
    Is there any way by which i can automatically get this portlet namespace within the param tag in the jsp.
    I know for a fact that within javascript tags, it can be used as <portlet:namespace/> as shown below :-
    <script type="text/javascript">
    function doSomething()
    buttonId= 'view' + '<portlet:namespace/>'+':'+'formName:buttonId';
    document.getElementById(buttonId).disabled = true;
    </script>
    Kindly treat this on high priority.
    Thanks and Regards,
    Darshan Shroff

    Perhaps so.
    I need to use it within param as below
    <h:inputText value="#{bean.userid}"
    required="#{!empty param['viewns_7_CGAH47L00GLRE0I0BCOUKS00I5_:form:login']}" />
    Here 'viewns_7_CGAH47L00GLRE0I0BCOUKS00I5_:form:login' is actually
    'view' + '<portlet:namespace/>'+':'+'formName:buttonId';
    I am just trying to check the presence of the client ID in the request paramameter map inorder to attain action dependent requiredness.
    Kindly tell me how i could access it within param.
    Thanks & Regards,
    Darshan Shroff

  • JSP: attributes for body ?

    I never used JSPs all that much and mostly worked with servlets. I just wonder (because it's hard to find anything about it): how would I e.g. add an ununload event handler to a <body> tag? Whatever I do, the JSP generates header and body itself and I can only modify the body content.
    How would I get <body onunload="javascript:afunction()"> into my HTML from a JSP? I'm stumped. Currently it works because I add another nested body tag and the browsers accept it nevertheless. But that's no real solution.

    BalusC wrote:
    Just open the JSP file in a text editor/IDE, add the desired line and save the file?That's what I currently do. It leads to
    <html>
    <head>
    </head>
    <body>
      <body onunload="...">
      </body>
    </body>Which thankfully works because the browsers seem tolerant enough.
    There must be more into the story. Maybe an IDE which is preventing you from doing that. Or a framework which doesn't let you to have the full control over the code. Or so.I suppose the latter, and the portlet stuff getting in my way. The IDE should have nothing to do with that.

  • Howto optionally include an attribute on an element in a JSP document ?

    I cannot find a way to optionally include an attribute on an element in a JSP document (JSPX). My JSP document is used to create an XML according to an XML schema where some element are declared as optional by the schema (default for element attributes).
    I've tried:
    a)
    <elem <c:if test="${!empty obj.attr}">attr=${obj.attr}</c:if>>
    </elem>b)
    <jsp:element name="elem">
       <c:if test="${!empty obj.attr}">
          <jsp:attribute name="attr">${obj.attr}</jsp:attribute>
       </c:if>
       <jsp:body>
       </jsp:body>
    </jsp:element>And none of them work. Any ideas?

    I cannot find a way to optionally include an attribute on an element in a JSP document (JSPX). My JSP document is used to create an XML according to an XML schema where some element are declared as optional by the schema (default for element attributes).
    I've tried:
    a)
    <elem <c:if test="${!empty obj.attr}">attr=${obj.attr}</c:if>>
    </elem>b)
    <jsp:element name="elem">
       <c:if test="${!empty obj.attr}">
          <jsp:attribute name="attr">${obj.attr}</jsp:attribute>
       </c:if>
       <jsp:body>
       </jsp:body>
    </jsp:element>And none of them work. Any ideas?

  • Generic id attribute in jsp:useBean

    hi!
    i use JSP 1.2 and would like to fill the id-attribute with a constant that i have declared in an interface. I import this interface into my jsp and then write
    <jsp:useBean id='%= Constants.REQ_ATTRIB_ARTICLEBEAN %'
    class="com.my.content.ArticleBean" scope="request"/>FAILURE: "JspTranslate: Runtime Expr Value
    "%=Constants.REQ_ATTRIB_ARTICLEBEAN %" is not permitted for attribute
    "id" for jsp element jsp:useBean."
    I tried also the following, but it didn't work either...
    <jsp:useBean class="com.my.content.ArticleBean" scope="request">
      <jsp:attribute name="id">
        <%= Constants.REQ_ATTRIB_ARTICLEBEAN %>
      </jsp:attribute>
    </jsp:useBean>FAILURE: "JspTranslate: jsp:useBean is missing an id attribute."
    Thanks for the help!

    Isnt the error message succint enough ?
    FAILURE: "JspTranslate: Runtime Expr Value
    "%=Constants.REQ_ATTRIB_ARTICLEBEAN %" is not permitted for attribute
    "id" for jsp element jsp:useBean."IMO, you cannot use Runtime expressions for the id attribute values.
    cheers,
    ram.

  • JSP 2.0 Tag files outputting elements with conditional attributes

    It appears to be impossible to conditionally output element-attributes in JSP 2.0 XML Tag files. Here's an example:
    Tagfile text.tagx:
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
      <jsp:directive.attribute name="name" required="true" type="java.lang.String"/>
      <jsp:directive.attribute name="id" required="false" type="java.lang.String"/>
      <jsp:text>
        <input type="text" name="${name}" id="${id}" />
      </jsp:text>
    </jsp:root>Seems simple enough. This tag has a name-attribute and an optional id-attribute. But what if I want the id-attribute of the 'input' element not to be outputted when the id-parameter is empty!
    It appears there's no elegant way to do this but to revert to CDATA blocks and/or output-escaping. Is this an oversight in the API or am I missing something?
    I've also tried the following but it didn't work (in Tomcat anyway):
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2" xmlns:c="http://java.sun.com/jsp/jstl/core">
      <jsp:directive.attribute name="name" required="true" type="java.lang.String"/>
      <jsp:directive.attribute name="id" required="false" type="java.lang.String"/>
      <jsp:text>
        <jsp:element name="input">
          <jsp:attribute name="type" value="text"/>
          <jsp:attribute name="name" value="${name}"/>
          <c:if test="${!empty id}">
            <jsp:body>
              <jsp:attribute name="id" value="${id}"/>
            </jsp:body>
          </c:if>
        </jsp:element>
      </jsp:text>
    </jsp:root>Any ideas on how to do this?

    I wonder why no one has responded to this post!!!! I am trying to do the same thing, to no avial. In XSLT this is how it works, I would have thought JSTL would do the same thing. D'oh!

  • Values from a jsp page are null in Action Class

    hi, i am working on an application...i have a jsp page with several inputs (type=text) and when a submit the form to to my action class all values      received are null.
    Here is a part of code:
    the jsp file: letter.jsp
    <form target="_self" action="/Test/editLetter.do" name="letterTF">
    <table>
    <tbody>
    <tr>
    <th>
    No of objects
    </th>
    <th>
    Weight
    </th>
    <th>
    Description
    </th>
    </tr>
    <tr>
    <td>
    Package
    <input name="package" id="package" type="checkbox">
    </td>
    <td>
    <input name="package_No" type="text" value="<%=currentBean.getPackageNo() %>"> <%-- from session...have to edit some date from a data base--%>
    </td>
    <td>
    <input name="package_weight" type="text" value="<%=currentBean.geWeight()%>">
    </td>
    <td>
    <input name="description" type="text" value="<%=currentBean.Description()%>"
    </td>
    </tr>
    <tr>
    ..................................................... <%-- It's a big form --%>
    </tr>
    <tr>
    <input type="submit" name="send" value="Send">
    </tr>
    </tbody>
    </table>
    </form>
    struts-config.xml:
    <form-bean
              name="letterTF"
              type="Test.LetterForm">
    </form-bean>
    <action path="/editLetter"
                   type="Test.LetterAction"
                   name="scrisoareTF"
                   input="/letter.jsp"
                   scope="request"
                   validate="false">
                   <forward name="success" path="/index_orders.jsp"/>
    </action>
    The ActionForm class:
    public class LetterForm extends ActionForm{
    private String package;
         private String package_No;
         private String package_weight;
         public void setPackage(String package){
    this.package = package
    public String getPackage(){
    return package;
    The action class:
    public class LetterAction extends Action{
    public ActionForward execute(     
                   ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response)
         throws Exception{
    String package;
    String package_No;
    String package_weight;
    LetterForm letterTF = (LetterForm) form;
    package = letterTF.getPackage();
    package_No = letterTF.getPackageNo()
    package_weight = letterTF.getPackageWeight();
    System.out.println("Package: "+package);//it will print Package: null
    System.out.println("Weight: "+weight);//it will print Weight: null
    System.out.println("Description "+description) //it will print Description: null
    As I observed its not making the set methods from LetterForm.java
    I am dealing with this bug for a couple of days an i didn't managed to break it. If anyone has an idea would he be so kind to share it with me.
    Thanks in advanced,
    David

    Basically your form beans are the place holders or containers for your jsp attributes. It has to be mapped in such a way that when the form is submitted the user entered values get populated on to your form bean.
    For Eg:
    JSP
    <html:form action="accountSearchResults.do">
    <html:text property="myName" size="15"/>
    //USE ONLY STRUTS TAGS IN JSP's. U CAN REFER TO
    //http://struts.apache.org/1.x/struts-taglib/tlddoc/index.html
    //THE PROPERTY NAME "myName" SHOULD BE DEFINED IN
    //YOUR FORMBEAN WITH getMyName AND setMyName
    //METHODS DEFINED
    </html:form>
    struts-config.xml
    <form-beans>
         <form-bean name="addEditAccount" type="org.apache.struts.validator.LazyValidatorForm">
              <form-property name="myName" type="java.lang.String">
              </form-property>
         </form-bean>
    </form-beans>
    <action-mappings>
         <action path="/accountSearchResults" type="com.zzz.AccountSearchResultAction" name="addEditAccount" scope="request">
              <forward name="success" path="NextPage.jsp">
              </forward>
         </action>
    </action-mappings>
    Action Class
    Since we have defined the form bean as a lazyvalidator instance you can use:
    PropertyUtils.copyProperties(targetBean, form);to fetch the values entered by the user. Try to use struts tags in your jsp's and map the properties to your form bean variables. Hope that helps.
    SirG

  • Values from a jsp page are null in an Action class

    hi, i am working on an application...i have a jsp page with several inputs (type=text) and when a submit the form to to my action class all values received are null.
    Here is a part of code:
    the jsp file: letter.jsp
    <form target="_self" action="/Test/editLetter.do" name="letterTF">
    <table>
    <tbody>
    <tr>
    <th>
    No of objects
    </th>
    <th>
    Weight
    </th>
    <th>
    Description
    </th>
    </tr>
    <tr>
    <td>
    Package
    <input name="package" id="package" type="checkbox">
    </td>
    <td>
    <input name="package_No" type="text" value="<%=currentBean.getPackageNo() %>"> <%-- from session...have to edit some date from a data base--%>
    </td>
    <td>
    <input name="package_weight" type="text" value="<%=currentBean.geWeight()%>">
    </td>
    <td>
    <input name="description" type="text" value="<%=currentBean.Description()%>"
    </td></tr>
    <tr>
    ..................................................... <%-- It's a big form --%>
    </tr>
    <tr>
    <input type="submit" name="send" value="Send">
    </tr>
    </tbody>
    </table>
    </form>
    struts-config.xml:
    <form-bean
    name="letterTF"
    type="Test.LetterForm">
    </form-bean>
    <action path="/editLetter"
    type="Test.LetterAction"
    name="scrisoareTF"
    input="/letter.jsp"
    scope="request"
    validate="false">
    <forward name="success" path="/index_orders.jsp"/>
    </action>
    The ActionForm class:
    public class LetterForm extends ActionForm{
    private String package;
    private String package_No;
    private String package_weight;
    public void setPackage(String package){
    this.package = package
    public String getPackage(){
    return package;
    The action class:
    public class LetterAction extends Action{
    public ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception{
    String package;
    String package_No;
    String package_weight;
    LetterForm letterTF = (LetterForm) form;
    package = letterTF.getPackage();
    package_No = letterTF.getPackageNo()
    package_weight = letterTF.getPackageWeight();
    System.out.println("Package: "+package);//it will print Package: null
    System.out.println("Weight: "+weight);//it will print Weight: null
    System.out.println("Description "+description) //it will print Description: null
    As I observed its not making the set methods from LetterForm.java
    I am dealing with this bug for a couple of days an i didn't managed to break it. If anyone has an idea or a solution would he be so kind to share it with me
    Thanks in advance,
    David

    Basically your form beans are the place holders or containers for your jsp attributes. It has to be mapped in such a way that when the form is submitted the user entered values get populated on to your form bean.
    For Eg:
    JSP
    <html:form action="accountSearchResults.do">
    <html:text property="myName" size="15"/>
    //USE ONLY STRUTS TAGS IN JSP's. U CAN REFER TO
    //http://struts.apache.org/1.x/struts-taglib/tlddoc/index.html
    //THE PROPERTY NAME "myName" SHOULD BE DEFINED IN
    //YOUR FORMBEAN WITH getMyName AND setMyName
    //METHODS DEFINED
    </html:form>
    struts-config.xml
    <form-beans>
         <form-bean name="addEditAccount" type="org.apache.struts.validator.LazyValidatorForm">
              <form-property name="myName" type="java.lang.String">
              </form-property>
         </form-bean>
    </form-beans>
    <action-mappings>
         <action path="/accountSearchResults" type="com.zzz.AccountSearchResultAction" name="addEditAccount" scope="request">
              <forward name="success" path="NextPage.jsp">
              </forward>
         </action>
    </action-mappings>
    Action Class
    Since we have defined the form bean as a lazyvalidator instance you can use:
    PropertyUtils.copyProperties(targetBean, form);to fetch the values entered by the user. Try to use struts tags in your jsp's and map the properties to your form bean variables. Hope that helps.
    SirG

  • Bean not working in jsp

    OK, maybe I'm oversharing, but I want to be thorough. Note I asked this question a different way using very different code.
    Here's my jsp file - myq.jsp
    <%@ page language="java" import="java.util.*,com.serco.inquire.*" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="inq" tagdir="/WEB-INF/tags" %>
    <inq:displayCollection>
    <jsp:attribute name="mgr">Chris Novish</jsp:attribute>
    </inq:displayCollection>Here's displayCollection.tag used by that jsp:
    <%@ tag body-content="scriptless" import="com.serco.inquire.*" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ attribute name="mgr" required="true" %>
    <jsp:useBean id="irc" scope="session" class="com.serco.inquire.IrCollection">
      <jsp:setProperty name="irc" property="mgrid" value="${mgr}" />
    </jsp:useBean>
    ${irc.size} | ${irc.mgrid}Here's the java class IrCollection (used as a bean in the tag):
    package com.serco.inquire;
    import java.sql.*;
    import java.util.*;
    public class IrCollection {
         public ArrayList iRecords = new ArrayList<InquireRecord>();
         public int size;
         public String mgrid;
         public irCollection() {
              super();
         public void populateCollection() {
              try {
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   String filename = "inquire.mdb";
                   String database = "jdbc:odbc:Driver={Microsof Access Driver (*.mdb)};DBQ=";
                   database+= filename.trim() + ";DriverID=22;READONLY=true}";
                   Connection con = DriverManager.getConnection( database ,"","");
                   Statement s = con.createStatement();
                   s.execute ("SELECT * FROM inquiries WHERE manager = '" + this.mgrid + "'");
                   ResultSet rs = s.getResultSet();
                   int cur;
                   while (rs.next()) {
                        cur = rs.getRow()-1;
                        InquireRecord localIR = new InquireRecord();
                        int curID = rs.getInt("ID");
                        localIR.setID(curID);
                        String cursub = rs.getString("submitter");
                        localIR.setSubmitter(cursub);
                        this.iRecords.add(cur, localIR);
                   con.close();
                   this.size = iRecords.size();
              catch (Throwable e) {
                   System.out.println(e);
         public int getSize () {
              return this.size;
         public void setMgrid(String datum) {
              this.mgrid = datum;
              this.populateCollection();
         public String getMgrid() {
              return this.mgrid;
    }and here's the InquireRecord java class used by IrCollection:
    package com.serco.inquire;
    public class InquireRecord {
         private int ID;
         private String submitter;
         public InquireRecord() {
              super();
         public InquireRecord(String asubmitter) {
              this.submitter = asubmitter;
         public int getID(){
              return this.ID;
         public void setID(int datum) {
              this.ID = datum;
         public String getSubmitter() {
              return this.submitter;
         public void setSubmitter(String datum) {
              this.submitter = datum;
    }The JSP does this: set the mgr variable, which is passes to the tag, the tag then creates an instance of IrCollection using that mgr variable. (Yes, putting that populateCollection() method call in the setMgrid() method is probably Bad Practice, but it works, usually). The IrCollection objects builds an ArrayList of InquireCollection objects from an Access database. It then sets it's size property based on how many InquireCollection instances it put into the ArrayList. Once that's all done, the tag spits out 2 things: The size property and the mgrid property.
    When I view the JSP, it gives me 0 for the size and Chris Novish for the mgrid.
    I think this could be one of the following:
    *Not finding any matching records of the database
    *Not actually executing the populateCollection() method
    *some how forgetting the information it put into that ArrayList?
    I"m sure there's another possibility, but I don't know.
    Here's what gets me. Here's a test class I made called TestCollection:
    {code}package com.serco.inquire;
    import java.util.*;
    import java.text.*;
    public class TestCollection {
         public static void main(String[] args) {
              IrCollection myCollection = new IrCollection();
              myCollection.setMgrid("Chris Novish");
              System.out.println(myCollection.getSize());
              System.out.println(myCollection.getMgrid());
    }{code}
    if I run that I get a size of 4 and a mgrid of Chris Novish.
    Same data in, and it works as expected.
    So... why won't JSP do it?

    You have defined a session scope for that bean. You have to make sure that the bean is instantiated by this jsp and not earlier. If the bean is located in the session because it was set earlier, then the body tags within useBean are not evaluated.
    Look here - http://java.sun.com/products/jsp/tags/syntaxref.fm14.html#8865
    An easy way to test it would be to change the scope of the bean to request.
    ram.

  • How to evalute the name of an attribute at runtime?

    hi, I have a custom tag that accepts dynamic attributes. I would like to pass attributes names that are defined at run time, by EL, but didn't find a way to do it
    this is what I tried without success
    ${name1} <!-- "email" -->
    ${name2} <!-- "username" -->
    <mytags:customtag>
       <jsp:attribute name="${name1}"> some jsp here </jsp:attribute>
       <jsp:attribute name="${name2}"> some jsp here </jsp:attribute>
    </mytags:customtag>it seems that jsp:attribute name attribute is rtexprvalue="false", so it doesn't evaluate name1 to "email".
    Is there a way to do what I'm trying here?
    Edited by: DMD_ANFINI on Apr 12, 2010 2:23 PM

    You can use dynamic attributes for custom tags created with tag file. Please see the sample code given below;
    <%@ tag body-content=’empty’ dynamic-attributes=’tagAttrs’%>
    <%@ attribute name=’optionsList’ type=’java.util.List’ required=’true’ rtexprvalue=’true’ %>
    <%@ attribute name=’name’ required=’true’ %>
    <%@ taglib uri=”http://java.sun.com/jsp/jstl/core” prefi x=”c” %>
    <select name=’${name}’
    <c:forEach var=”attrEntry” items=”${tagAttrs}”>
        ${attrEntry.key}=’${attrEntry.value}’
    </c:forEach>
    >
    <c:forEach var=”option” items=”${optionsList}”>
        <option value=’${option}’> ${option} </option>
    </c:forEach>
    </select>A * R

  • Spec oversight? Using dynamic-attributes in XML tag files

    I have a couple of tagfiles that generate form elements with specific conventions for the 'name' and 'value' attribute. Basically, a data binding framework.
    Dynamic attributes are useful because you can delegate all the usual html attributes to the generated HTML form element: SELECT, INPUT, id, class etc.
    The usual way to do this is to concatenate all the "pass-through" attributes to a string, and append this string to the element generated:
    <input type="hidden" name="foo" ${dynattrs}/>I'm wondering how to do this in a tagfile in XML format (mytag.tagx), since the XML format forbids syntax like in the example above.
    jsp:attribute won't help much, if it's nested inside a c:forEach: it won't apply to the right element.

    Ran into the same problem with 'optional attributes'. (see post "JSP 2.0 Tag files outputting elements with conditional attributes" http://forum.java.sun.com/thread.jspa?forumID=45&threadID=681033)
    Found a solution that is not very elegant but does work and saves you the trouble of reverting to Java Tags. Consider the following tag-file that outputs an html input-tag with conditional attributes:
    <?xml version="1.0" encoding="utf-8"?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2"
         xmlns:c="http://java.sun.com/jsp/jstl/core">
         <jsp:directive.attribute name="name" required="true" type="java.lang.String"/>
         <jsp:directive.attribute name="id" required="false" type="java.lang.String"/>
         <jsp:directive.attribute name="value" required="false" type="java.lang.String"/>
         <jsp:directive.attribute name="disabled" required="false" type="java.lang.Boolean"/>
         <jsp:directive.attribute name="hint" required="false" type="java.lang.String"/>
         <jsp:directive.attribute name="cssClass" required="false" type="java.lang.String"/>
         <jsp:text><![CDATA[<input type="text" name="]]><c:out value="${name}"/><![CDATA["]]></jsp:text>
         <c:if test="${!empty id}"><![CDATA[ id="]]><c:out value="${id}"/><![CDATA["]]></c:if>
         <c:if test="${!empty cssClass}"><![CDATA[ class="]]><c:out value="${disabled?(cssClass + '-disabled'):cssClass}"/><![CDATA["]]></c:if>
         <c:if test="${disabled}"><![CDATA[ disabled="disabled"]]></c:if>
         <c:choose>
              <c:when test="${!empty value}"><![CDATA[ value="]]><c:out value="${value}"/><![CDATA["]]></c:when>
              <c:when test="${!empty hint}"><![CDATA[ value="]]><c:out value="${hint}"/><![CDATA[" onfocus="if(this.value==']]><c:out value="${hint}"/><![CDATA[')this.value='';"]]></c:when>
         </c:choose>
         <jsp:text><![CDATA[/>]]></jsp:text>
    </jsp:root>In answer to your question: Yes, it looks like an oversight. Using the jsp:attribute tag in a c:forEach doesn't work because the attribute is then applied to the forEach tag. You would have to put the attribute-tag inside a jsp:body tag (inside the forEach). Then it would apply not to the forEach tag but to the tag enclosing the forEach. However, this doesn't work either, or at least it doesn't work in Tomcat 5.5. Could be a bug though, JSP 2.0 is still very buggy (for instance, using a tagfile inside another tagfile from the same taglib doesn't seem to work either...)
    Anyway, if you ever find a good solution please let me know by posting to this topic!
    TIA

  • Evaluating actions in jsp:import Fragments

    Greetings,
    I'm using JSP fragments for the first time and encountered some surprises where the fragment did not evaluate as expected. The fragment evaluates fine when it is a block of JSP code, but if I put the same code into a separate JSP file and include it, the block does not get processed in the same way. For example:
    <my:tagFoo foo="bar">
    <jsp:attribute name="content">
    <jsp:include page="MyPage.jsp" flush="false"/>
    </jsp:attribute>
    </my:tagFoo>
    Some strings get substituted as expected, but control statements like <c:forEach ...> remain literal text and are never processed. I've tried the "MyPage.jsp" in a non-fragment context and verified that it works fine. Is there a way to get the tag with the jsp:invoke part to fully process the included page?
    If I put the same fragment block into a separate tag (my preferred approach), other errors get thrown at control statements during the jsp:invoke.
    Any help appreciated!
    -Daniel

    Thanks, for the response! I kept reducing the code in the "my:tagFoo" tag that called the invoker until it was minimalistic -having the essential headers and just the jsp:invoke line with an echo of the content generated. I did try changing the "body-content" to the other valid values but it didn't help, perhaps a line is missing?
    <%@ tag body-content="empty" %>
    <%@ attribute name="content" fragment="true" required="true" %>
    <%@ attribute name="foo" required="true" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
    <%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
    <jsp:invoke fragment="content" var="output"/>
    <xmp>
    ${output}
    </xmp>

  • JSP Form to many pages

    Hi,
    I have the following application structure:
    PersonalDetails.jsp
    Attributes: UserName, FirstName Surname etc..
    AccountDetails.jsp
    Attributes: Address, Payment Information etc..
    RegistrationConfirmation
    To manage the user registration, I am using one Bean and setting the values by using FORM POST action. So when the user clicks the NEXT button (which is the submit button). It passes all the details to the bean and forwards the user to the next page.
    Question How can I provide a BACK button? The page for the next button is in action="..." of the FORM...
    Thanks in advance!
    Kind regards
    Angus

    Your bean is in the session scope, yes? The fields for each form is different? If you provide a button or link that go to the PersonalDetails.jsp page, it should have the effect of going back. If you want to submit the current page to store those values, then you need to have 2 submit buttons. You might need to use Javascript to set a hidden command field in the form to tell it whether it's a forward or back submission.
    The key to using the same bean in multiple pages is to not reset the bean each page. Or if you do, then make sure you provide some argument that the page can use to differenciate between a new user and a "back".

Maybe you are looking for

  • Why does Firefox keep installing Miro with every new update ?

    Some months ago I downloaded Miro, although I never made much use of it.After the recent Firefox update to 3.6.4 I noticed that used memory suddenly jumped by around 20 % and when I investigated in Resource Monitor I found that Miro had started runni

  • Functionality of the function module - FAGL_GET_OPEN_ITEMS_GL

    Hi, I would like to know regarding the working of the module FAGL_GET_OPEN_ITEMS_GL, and details about the parameters to be passed to the function module and the returned values. thanks.

  • PrintWindow() API does NOT get an image for Windows created by Java?

    Hi WinXP added the PrintWindow() API that allows one application to take an image copy of another app's window, even if the window is off-screen or obscured, ie beyond the scope of a simple BitBlt. (PrintWindow seems to be a cross-process "extension"

  • Xml - csv

    I have created an temp.xml file from a couple other source xml's. I am using this temp.xml and an xslt I created to output text in a csv format. Unfortunately I am seeing the data in the text file incorrectly and I am not sure why. I see somethign li

  • Error handler for ORA-29283 - not working

    I am running Oracle 9.2.0.4 on HP-UX. I have a stored procedure which reads a text file. I have set up an execption for error code ORA-29283 (invalid file operation). When I test my procedure (by not having the file to read) my exception handler is b