JSP 1.2: jsp expression in attribute value doesn't parse.

Hi, I'm trying to use a jsp:expression in an html attribute value in JSP 1.2 but jasper doesn't seem to be able to parse it correctly. I'm using the XML syntax in my jsp, the relevant snippets are as follows:
<jsp:scriptlet>
String versionedPath = "/mysite/2.1/images";
</jsp:scriptlet>
<img src="%= versionedPath %/foo.jpg" />
The JSP documentation claims that this will work but I'm beginning to think this syntax won't work when using JSP's XML syntax. I already know that the following won't work:
<img src="<jsp:expression> versionedPath </jsp:expression>/foo.jpg" />
as it did in JSP 1.1 because it's not well-formed xml.
Is it even possible to use jsp expressions in attribute values when using JSP 1.2's XML syntax? If so, please enlighten me, and if not, well, that seems pretty broken to me.
TIA...
--Stuart

you should use this:
<img src=<%= versionedPath %>/foo.jpg >

Similar Messages

  • Using Scriptlet expressions as attribute values in taglibs

    Hi,
              While calling a custom tag in a JSP page that has attributes set up to
              accept scriptlet expressions in the TLD, a space is required before and
              after the variable like in <abc:xyz attr1=<%= xyz %> />
              otherwise, the JSP page does not compile. Using Weblogic 5.1.0 SP5 on
              Windows NT.
              

    Runtime expression values work fine. Sounds like an unbalanced tag problem.
              Inproperly quoted strings?
              "Jason Southern" <[email protected]> wrote in message
              news:3c644246$[email protected]..
              >
              > I'm running WL6.1 SP1 on Windows 2000 and I cannot seem to get WebLogic to
              handle
              > runtime expression values for taglib attributes. I'm using a standard
              container
              > tag (no empty body) and I receive the following error:
              >
              > Parsing of JSP File '/file.jsp' failed:
              > no corresponding open tag for tag extension close: //[ null;
              >
              > I have the declared the the tag attribute in the TLD to allow for runtime
              expressions
              > in the TLD (<rtexprvalue>true</rtexprvalue>).
              >
              > Anyone else had this problem. Is this a known bug?
              >
              > "Suneel Parthasarathy" <[email protected]> wrote:
              > >Hi,
              > >While calling a custom tag in a JSP page that has attributes set up to
              > >accept scriptlet expressions in the TLD, a space is required before and
              > >after the variable like in <abc:xyz attr1=<%= xyz %> />
              > >otherwise, the JSP page does not compile. Using Weblogic 5.1.0 SP5 on
              > >Windows NT.
              > >
              > >
              >
              

  • Xml/html to jsp - problem with quotes in attribute values

    I am trying to convert a static html document into a jsp using an xsl stylesheet, but run into problems trying to use the jsp expression syntax inside of attribute values.
    Here is a sample of the source file:
    <input type="text" name="firstName" value=""/>
    Here is what I want the resulting jsp file to look like:
    <input type="text" name="firstName" value="<jsp:expression>customer.getField("firstName") </jsp:expression>">
    Here is what part of my stylesheet looks like:
    <xsl:template match="input">
    <xsl:copy>
    <xsl:copy-of select="@type"/>
    <xsl:copy-of select="@name"/>
    <xsl:attribute name="value">
    <xsl:text disable-output-escaping="yes"><jsp:expression></xsl:text>
    <xsl:text disable-output-escaping="yes">customer.getField(</xsl:text>
    <xsl:text disable-output-escaping="yes">"</xsl:text>
    <xsl:value-of select="@name"/> ")
    <xsl:text disable-output-escaping="yes">")</xsl:text>
    <xsl:text disable-output-escaping="yes"></jsp:expression></xsl:text>
    </xsl:attribute>
    </xsl:copy>
    </xsl:template>
    The problem i have is with the <%= customer.getField("firstName") %>. I have tried several different ways of inserting the double quotes around firstName, but no matter what I try, it always uses the entity reference instead of actually putting the " character. The jsp container will not accept the entity.
    I am assuming that the problem is with trying to place double quotes inside of an attribute value. Any ideas how to get around this?
    Thanks
    David

    Which App Server are you using?
    You should just be able to escape the double quotes.
    If that doesn't work, it's a bug in the app-server.
    Alternatively, you can use single quotes around the
    attribute value.
    Hope that helps,
    AlexSorry, I'm an idiot. By escaping you meant the unicode character escape "\u0022". I had not tried that. However, once i realized what you meant, I tried it, and it worked. Thanks for your help.
    David

  • Please help ... evaluating jsp:expression in attributes

    Dear All,
    I have searched the forum and found a few posts expressing a similar problem. However none seemed to divulge any solution.
    <option value="<jsp:expression> signals[count] </jsp:expression>"><jsp:expression> signals[count] </jsp:expression></option>In the code above the second expression evaluates fine but the first causes problems. Its the angle brackets of the jsp:expression:
    The value of attribute "value" must not contain the '<' characterI have also tried <%= %> and %= % as has been suggested in previous posts
    <%= => fails also because of the angle brackets
    %= % is set to the value, instead of the evaluated expression.
    Am Completely Stumped. Surely there must be a way to do this!?!
    Thanks is advance

    Hi Steve, thanks for your help I have resolved the problem. Somewhere in the J2EE Tutorial I found a snippet of code that talked about using CDATA tags.
    My working code now looks like this:
    <td><select name="signal_list" multiple="multiple">
        <jsp:useBean id="signalslist" class="acreweb.SignalsList" scope="session" />
            <jsp:scriptlet>
                int count = 0;
                System.out.println("useBean");
                String[] signals = signalslist.getSignals();
                while(count < signals.length)
         //Display signal names in select box
         System.out.println(signals[count]);
         </jsp:scriptlet>
              <![CDATA[<option value=']]><jsp:expression>new String(signals[count])</jsp:expression><![CDATA[' />]]><jsp:expression> signals[count] </jsp:expression>
         <jsp:scriptlet>     
         count++;
               </jsp:scriptlet>
        </select>
    </td>Sorry about formatting am being dragged to the pub, impatient work colleagues

  • 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 pass attribute values through variables in JSP  Custom TagLib

    Hi,
    Can anybody help me how to pass values through varuables in the jsp custom tag.
    i am using JSP custom tag. I am unable to pass attribute values through variables.
    <invitation:invdetails invid="<%=invid%>"/> The value is passing as <%=invid%> ,not value of the invid.
    But i am getting throuh the fllowing
    <invitation:invdetails invid='1' />
    Please anybody suggest me how to pass value by using the variable.

    Hi,
    It sounds like you need to set the <rtexprvalue> tag to true in the TLD for your tag. If you do this the tag will read in the value you are trying to pass to it.
    dapanther...

  • 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();
                   }

  • Attribute HR_NTF_EMBEDDED_REGION with value JSP:/OA_HTML/OA.jsp?OAFunc=-&HR

    Hi,
    Env:
    Oracle EBS :oracle11.5.10.2
    Oracle DB :9.2.0.8
    OS version :AIX 5.3
    we are getting below error in HR self service
    Attribute HR_NTF_EMBEDDED_REGION with value JSP:/OA_HTML/OA.jsp?OAFunc=-&HR_EMBEDDED_REGION-&NtfId=-&#NID- refers invalid framework URL.
    How can i fix the issue?
    Thanks

    Hi;
    It was working before? If yes what have been changed? Is there invalid object on your db? Is there any additional info at apache log?
    Regard
    Helios

  • 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?

  • JSP Custom Tag and Expressions for parameters

    This should be an easy question. I am trying to use an expression for a
              parameter to a jsp or custom jsp tag. When I hard code a value for the
              parameter, the tag works fine but when I use the expression, the expression
              gets evaluated but the tag itself does not resulting in the tag being shown
              in my output.
              For example:
              <jsp:forward page="www.slashdot.org"/> works
              <jsp:forward page="<%=request.getParameter("DESTINATION")%>"/>
              places the following into my html output
              <jsp:forward page="www.slashdot.org"/>
              Can someone please tell me what I am doing wrong or at least offer some
              debugging hints?
              Thanks in advance!
              Jacob Meushaw
              

    I have experienced almost this exact same problem, but with a custom
              tag. And I did make sure that my attribute specified
              <rtexprvalue>true</rtexprvalue>. Here is the weird part.
              If I do the following JSP code everything works fine:
              <% String foo = request.getParameter("bar"); %>
              <mytag:custom param="<%= foo %>"/>
              But if I do this:
              <mytag:custom param="<%= request.getParameter("bar") %>"/>
              I get the following in my html output:
              <mytag:custom param="whatever bar is set to in the request"/>
              It appears that the JSP container only does a one pass evaluation.
              Is this the spec of is this a bug?
              Jacob Meushaw wrote:
              >
              > This should be an easy question. I am trying to use an expression for a
              > parameter to a jsp or custom jsp tag. When I hard code a value for the
              > parameter, the tag works fine but when I use the expression, the expression
              > gets evaluated but the tag itself does not resulting in the tag being shown
              > in my output.
              >
              > For example:
              >
              > <jsp:forward page="www.slashdot.org"/> works
              >
              > <jsp:forward page="<%=request.getParameter("DESTINATION")%>"/>
              > places the following into my html output
              > <jsp:forward page="www.slashdot.org"/>
              >
              > Can someone please tell me what I am doing wrong or at least offer some
              > debugging hints?
              >
              > Thanks in advance!
              >
              > --
              > Jacob Meushaw
              Jeff Smith
              [email protected]
              BEA Systems, Inc.
              720-565-6613
              

  • Attribute value does not accepitng expression ???

    ]I am using Tomcat 5.0.28 and JSTL 1.0.6. I put the files standard.jar and jstl.ar within my web-app WEB-INF/lib folder. I made no changes in web.xml. Then I ran the following program as test.jsp
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <html>
    <body>
    <c:set var="hello" value="Hello World!"/>
    <c:out value="${hello}"/>
    </html>
    </body>
    I'm getting this error message <br>
    "According to TLD or attribute directive in tag file, attribute value does not accept any expression"

    With Tomcat5, you should be using JSTL1.1.
    The JSTL1.0 tags didn't let you use runtime expressions like <%= expr %> with your tags. Instead you had to use ${expr}.
    ${expr} is a runtime expression in JSP2.0, where it wasn't before.
    JSTL1.1 provides a new tld with the correct settings.
    You should be using JSTL1.1 and the uri:
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    See full spiel on JSTL vs Tomcat versions in this thread:
    http://forum.java.sun.com/thread.jspa?threadID=629437&tstart=0

  • Javax.servlet.jsp.el.ELException: Attempt to coerce a value of type

    I've written a web service to retrieve informations from the database based on a client's criteria. The service endpoint is the following:
    public WSMissionBean getProfiles( WSMissionBean mission, WSProfileBean profile ) throws java.rmi.RemoteException;
    The WSMissionBean object is as follows:
    public class WSMissionBean implements Serializable {
    private WSProfileBean[] lstProfile;
    private WSProfileBean[] lstProfileMoinsQualifie;
    private WSProfileBean[] lstProfileByPoste;
    private WSProfileBean[] lstProfileByCompetences;
    And WSProfileBean is an object containing just simple data types. The whole idea is to have an object which, besides the criteria entered by a client, holds differents arrays, each of which answers a certain number of criteria required by the client.
    The service is deployed correctly, and I can access it, from a stand alone simple program, to retrieve data from the database as expected. The big problem is when I try to show the results in a JSP page! And the error message is:
    javax.servlet.jsp.el.ELException: Attempt to coerce a value of type "[Lclient.WSProfileBean;" to type "java.lang.reflect.Array"
    My JSP pages are as follows:
    <table border=0 cellspacing=1 cellpadding=3>
       <%-- sessionScope.mission.profiles contain data return by the web service, and gr:listRenderer is a tag file to show the result--%>
       <gr:listRenderer list="${sessionScope.mission.profiles}" />
    </table>
    And in the tag file, I have
    <%@ attribute name="list" required="true" type="java.lang.reflect.Array" %>
    <c:forEach var="profile" begin="0" items="${list}">
         <tr>
         <c:set var="profileId" value="${profile.id}" />
         <c:if test="${profile.selected}" >
              <td bgcolor="#0099FF"><input type="checkbox" name="${profileId}" checked="checked"/></td>
         </c:if>
         <c:if test="${!profile.selected}" >
              <td bgcolor="#0099FF"><input type="checkbox" name="${profileId}"/></td>
         </c:if>
         <td bgcolor="#0099FF"><font face="Verdana, Arial" size="2">${profile.nom}</font></td>
         <td bgcolor="#0099FF"><font face="Verdana, Arial" size="2">${profile.preNom}</font></td>
         <td bgcolor="#0099FF"><font face="Verdana, Arial" size="2">${profile.fonction}</font></td>
         <td bgcolor="#0099FF"><font face="Verdana, Arial" size="2">${profile.competences}</font></td>
         <td bgcolor="#0099FF"><font face="Verdana, Arial" size="2">${profile.nbAnneeExperience}</font></td>
         <td bgcolor="#0099FF"><font face="Verdana, Arial" size="2"><a target="_blank" href="./doc/myCV.html"><image border="0" alt="CV d�taill�" src="./image/cv.gif"/></a></font></td>
         </tr>
    </c:forEach>
    I've been searching desperately for days on the web for an answer, but to no result! I appreciate if someone can give me some advice, explanation... Thanks in advance
    Van Binh

    java.lang.reflect.Array is NOT a class which represents an array.
    It is a class that provides several static methods for using on arrays.
    The type of your attribute should be Object[] - an array of Objects.
    That will be compatible with an array of any sort of object (but not with an int[] for instance)
    <%@ attribute name="list" required="true" type="java.lang.Object[]" %>

  • Getting the attribute value from a table from page def using el expression.

    Hi,
    Am using Jdeveloper 11.1.2.0.0 and have a requirement as follows for which a sample is been created. Requirement is as follows..
    1. Have a Taskflow that has a readonly table Employee.
    2. On clicking of a button called "route" checks if the selected row , Manager id attribute value = 200 then navigate to first page else if manager id attribute value is 200 then navigate to second page.
    Through the page def , if it has form , then we can access the attributes like #{data.view_FirstPageDef.ManagerId} . In case of acquiring the same attribute value from table using page def ? is what am unable to get..
    Have achieved the routing concept using the Router activity on Taskflow. But am unable to get the selected row attribute value of a table from the employee page def.. Can someone suggest on the same...
    Thanks and Regards,
    Vinitha G

    On the router, right click its icon in the task flow and create a page definition. Then in the page def file, add an iterator based on the same View Object from the table in the first page, then add a value attribute mapped to managerId in the View Object iterator. Finally in the router you can write EL expressions along the lines of #{bindings.ManagerId.inputValue = 200} or #{bindings.ManagerId.inputValue != 200}.
    CM.

  • Is it possible to pass selected value from one jsp to another jsp page?

    In my welcome page(in jsp), if the user is selecting some values, is it possible to pass those values to another jsp page and display?
    If yes, how can it be done?
    please help..

    Yes, you would have to make the motion from one page to the next submit a form. Then on the second JSP you can use request.getParameter("nameOfInputField") to get the value the user selected.

  • How can I get the value for static content of 1 jsp into another jsp

    Hi, I have a jsp which have a header ,now i want this header value in another jsp dynamically.Can u tell me how I can do it?

    What I want to know is that , is it possible to get the value of a static content of one jsp into another jsp,something like getParameter() method that we use to get the value of a field in the jsp to a servlet,or to another jsp,the only difference here is I do not have a field here but a static jsp content .

Maybe you are looking for

  • HT201303 How do I delete a credit card from payment options?

    How do I delete a credit card from payment options in the itunes store?

  • "Screen" is 1%(?) bigger than display

    Hi guys, I have an iPhone 4 running 4.2.1, and in the last couple of days, the screen has started "pulsing" - hard to describe, but whenever it changes - say exiting an app back to the home screen - its fine for maybe 1/2 a second and then the screen

  • Can pages be set to full stop with a double space tap

    Hi, Does anyone know if you can set pages (or use an app) to place a full spot after a double space bar tap? Thanks

  • Video Driver ugrade

    I have Adobe Photoshop CC installed and been having probelms accessing the standard Light filters and 3 D grahipic options. After several communications with their support they tell me my graphics card is out dated. A scan of my system says I am up t

  • JDBC deadlock on DriverSapDB.connect

    Hi, Today i get a JDBC dealock that i must shutdown and restart my application, i get the follow stack when investiganting the problem: "http-80-exec-15" daemon prio=10 tid=0x0000000056fa8800 nid=0x4860 runnable [0x000000004292f000..0x0000000042930c9