JSTL fmt:param tag question

<%@taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>
<fmt:message key="result_display">
     <fmt:param value="${resultBean.sourceNumber}"/>
     <fmt:param value="${resultBean.resultValue}"/>
</fmt:message>
As far as I can tell, the "value" attribute of the <fmt:param> tag is capable of taking an EL. And yet, the code above does not compile. I get the error message "According to TLD or attribute directive in tag file, attribute value does not accept any expressions". If I use the <fmt_rt:param> tag, everything works fine. Am I reading the spec wrong?

You're not reading the spec wrong, but I think you are using the wrong version of JSTL. Are you using Tomcat 5? (Or another JSP2.0 container?)
If so, you should be using JSTL1.1
It has a uri of "http://java.sun.com/jsp/jstl/fmt"
Note the extra /jsp in there.
Tomcat 5 treats ${  } as runtime expressions. To a JSP2.0 container, they ARE runtime expressions. Thus in JSTL 1.1, the fmt:param tag does accept runtime expressions.
In JSTL1.0 because the ${  } expressions WEREN'T understood by the container, they made the tags so as not to accept runtime expressions, and called their custom evaluator.
You are using the 1.0 uri, which specifies that it doesn't accept runtime expressions. It is complaining that ${ } is a runtime expression - so you must be using a JSP2.0 container.
In short: You probably have a JSP2.0 container, and should be using JSTL1.1 uri: <%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
Cheers,
evnafets

Similar Messages

  • JSP Compilation problem - fmt:param tags

    Weblogic server 9.1 throws validation errors for jstl fmt:param tags. Body content is present so I'm not sure why the validation error. My code appears below :
              <fmt:message key="project.overview.archived.error"><fmt:param>${fn:escapeXml(baseAppViewBean.currentProjectName)}</fmt:param></fmt:message>
              The error is :
              The page failed validation from validator: "A body is necessary inside the "fmt:param" tag, given its attributes.".

    Found a solution to the problem. As long as there is a space between the end of the fn tag and the closing fmt:param tag, it works in 9.1. The following code works-
              This issue has been filed with BEA and will be addressed in a patch or a version after 9.2.
              <c:set var="imgAlt"><fmt:message key="document.type.508"><fmt:param>${fn:escapeXml(documentUIBean.displayString)} </fmt:param>
              </fmt:message></c:set>

  • JSTL c:import tag question

    HI
    I have a question about how the <c:param> tag interacts with <c:import> tag.
    <c:import> tag can be used to import from relative URL's like <c:import url="target.jsp" /> , from absolute urls like <c:import url="http://www.espn.com" /> or from another web application on the same server by specifying the context attribute like <c:import context="/myotherwebapp" url="some.jsp" />
    we can use <c:param> tag as an optional child tag for <c:import> to send request parameter to the page it is loading. For absolute url sending request parameters makes sense beacuse the import will be treated as new request and original request object will not be passed . but for relative urls and including the page in different web application on same web server does the jsp container treat it as part of same original request and does the target page have access to the original request object ? if this is true then how can you set additional request parameters on the request object? because once the request object is craeted by jsp container you can only add/remove attributes on it but you can never add parameters on it.
    Now if the jsp container always creates new request object for each of the above included pages then these pages will not have access to original request parameters entered by the user. Is that not a limitation.
    I am a little bit confused . hopefully somebody can help me out.
    thanks

    the c:param tag are added to the url and are not set as request parameter.
    <c:import url="target.jsp">
       <c:param var="test" value="val">
    </c:import>then is will do an import like
    <c:import url="target.jsp?test=val"/>

  • Problem: Localisation with JSTL FMT and Struts

    Hello!
    I am working on my first project with JSP / Servlets including JSTL and Struts Tag Libraries.(plus tiles from JSTL)
    I am trying to use localised messages, to deploy a webshop in multiplle languages.
    I allready managed to accomplish that the messages are read out of a file ApplicationResources.en.properties and another one ApplicationResources.de.properties which will be chosen by the preferences of the browser (JSTL FMT:message tag).
    The strange this is, this only works the first time the servlets are compiled. After I opened the servlet once in my browser, I am allways seeing the message in that language that was used first, even if I set the the locale trough a link in the URL. I am using this code:
    http://localhost:8080/Inkrement18/buchladenseite.jsp?lang=en
    <c:if test='${param.lang == "de"}'>
    DE <fmt:setLocale value="de" scope="session" />
    <fmt:setBundle basename="ApplicationResources" scope="session" />
    </c:if>
    <c:if test='${param.lang == "en"}'>
    EN <fmt:setLocale value="en" scope="session" />
    <fmt:setBundle basename="ApplicationResources" scope="session" />
    </c:if>It seems to me, the servlet is compiled once, and afterwards the locale does not get checked anymore. Is that possible?
    When I delete the compiled servlets from the work directory by hand, my link to change the locale manually works once, till I delete the servlets again (the session does not get killed by deleting the servlets!)
    My webserver is Jakarta Tomcat 5.5.9 and IDE Is eclipse.
    I am not sure if it matters here, but the main page consists of 4 parts like banner, menu, main-page, footer which gets assembled trough "tiles".
    Most submenues like shopping basket / catalogue are action servlets, realised with struts, calling another .jsp page by forward.
    Any ideas are really apreciated - I have no idea where to look for the error!
    If you need any more input from my side, please let me know!
    Best regards
    Jan

    Hey Experts!
    Nobofy has a clue on this? I have really no clue where to start to look for the problem...
    Cheers...Jan

  • Question on Issue with fmt:formatNumber tag of jstl

    Hi,
    We have a web application that uses struts framework. In the action class,i am setting an attribute of request object like
    request.setAttribute("Val",new Double(11.25489));
    I am using jstl fmt:formatNumber function in the jsp page to format the value to 2 decimal places.
    <fmt:formatNumber value="${Val}" maxFractionDigits ="2" />
    When i access the jsp page,there is no display of anything.
    If i access using <c:out value="${Val}"/> ,it does print the value.
    Interestingly,tomcat does not generate any corresponding java file in its work area.
    Any clues...anybody ?
    Edited by: gbhakta on Oct 31, 2007 12:23 PM

    Ok you are setting the value in request scope?
    How does the control transfer from the Struts Action to your JSP page?
    Check the struts-config to see if that forward is configured as a "redirect". If that is so, your request attribute would be lost, because a redirect causes a new request.
    The following code prints out all request attributes that are currently in scope.
    It might help checking to see if your "Val" is in scope or not.
    Request scope attributes:
    <table border="1">
    <c:forEach var="attr" items="${requestScope}">
      <tr><td><c:out value="${attr.key}"/>a</td><td><c:out value="${attr.value}"/></td></tr>
    </c:forEach>
    </table>Cheers,
    evnafets

  • Jstl - fmt Tag problem

    hi..
    I am facing problem in jstl. I have written a jsp file which is using jstl, <fmt> tag when I execute this file its gives me an error
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: /dt.jsp(6,8) According to TLD or attribute directive in tag file, attribute value does not accept any expressions
         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:146)
         org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:955)
         org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:710)
         org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1441)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
         org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
         org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
         org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
         org.apache.jasper.compiler.Validator.validate(Validator.java:1489)
         org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:157)
         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:563)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.12 logs.
    Apache Tomcat/5.5.12
      my jsp file is give blow
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
    <html>
    <body>
    <h1>Formatting with the default locale</h1>
    <jsp:useBean id="now" class="java.util.Date" />
    Date: <fmt:formatDate value="${now}" pattern="yyyy-MM-dd HH:mm"/>
    Number: <fmt:formatNumber value="${now.time}" />
    </body>
    </html>
    I am using apache-tomcat-5.5.12 & java 1.5 on win XP
    please help me out.....
    thanks

    Hi
    Try using "sv_SE" locale.

  • Trouble with fmt:formatDate tag

    Hi, I'm using JSTL 1.2 with Tomcat 6.0.26. I have
    <jsp:useBean id="today" class="java.util.Date" scope="request" />
    <fmt:formatDate var="fmtToday" value="${today}" pattern="MM/dd/yyyy"/>but when I try and get the value of ${fmtToday}, I get an empty string. In other words, this produces output ...
    today: ${today}but this does not
    today: ${fmtToday}Any ideas why? - Dave

    Nope. Looks good to me. Tried it out and had no issues.
    So then the questions become
    - have you imported the fmt tag library? <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
    - what server are you using?
    - what version of JSTL?

  • JSTL fmt:setBundle and JSF

    I am converting the code and JSP pages I had from jsf ea4 to jsf rel 1
    My bundle is Labels.properties (.properties file)
    Now, my JSTL fmt:setBundle is not recognized . My jsp code is:
    <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
    <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
    <%@ taglib prefix="s" uri="http://jakarta.apache.org/struts/tags-faces"%>
    <fmt:setBundle basename="Labels" scope="session" var="labelsBundle"/>
    <f:view>
    <s:html locale="true">
         <head>
         <title><fmt:message bundle="${labelsBundle}" key="form.heading.login"/></title>
         <s:base/>
         <link href="style/wless.css" rel="stylesheet" type="text/css">
         </head>
         <body>
    <!-- Log in -->
         <stf:form action="/listProjectTasks.do" method="post" focus="loginID" >
    <h:output_text value="#{labelsBundle.label.login.loginID}" />
    I get the following exception:
    There has been an unspecified exception (javax.servlet.jsp.JspException: Illegal Model Reference in this context for expression 'labelsBundle.label.login.loginID'.)!
    This used to work in ea4 when I had the key/bundle attributes.
    How can I access my properties file at sessionScope using the #{} notation or else?
    Thanks,
    Gisella

    Thanks for the response.
    Now it works but I ran into a different problem.
    In my .properties file I have escape characters like  
    and now with this JSF release 1, they show literally as, for example:
    Login ID:&nbsp
    So looking at the HTML generated:
    <td class="textLabel">Login ID: </td>
    instead of what it used to be
    <td class="textLabel">Login ID: </td>
    Also if I have the simple:
    <h:output_text value=" " />
    the text rendered is
    instead of a non-breaking space.
    Is there a way to represent these characters?
    Other related question:
    looking at the specs for f:loadBundle, it says that the resource bundle is loaded into a Map in the request
    scope. I find this annoying, that all the time, for each request, this bundle data will be loaded into
    a Map in the request scope. These are values needed at the session scope.
    Is there a way to have this resource bundle loaded at the session scope as you can do it in JSTL?
    The f:loadBundle seems to be missing the 'scope' attribute as the fmt:setBundle does.
    Any suggestions?
    Gis

  • Getting img tags to work in sub page using jstl core import tag

    Am trying to bring disparate system page reports together under one web app. This means using the jstl core import tag (I dont want to redirect as I want to hide the urls, this web app provides better security than those it calls).
    Use of the import tag works to a degree but any resources (ie. img tags) don't load.
    Have created a much simplified example that demonstrates..
    So heres the jsp...
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <h3>Delivery Performance Report</h3>
    <c:url value="http://localhost/mycontext/subpage.html" var="myUrl"/>
    <c:import url="${myUrl}" />and a simple sub page (note plain html, no jsp, this mimics my project as the other systems are hidden source, non jsp)
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
    <HTML>
    <HEAD>
    <TITLE>sub page</TITLE>
    </HEAD>
    <BODY>
         This is the sub page<br>
         <img src="images/banner_image.jpg" />
    </BODY>
    </HTML>While I dont get any errors what I do get is ..
    Delivery Performance Report
    This is the sub page
    ...but image fails to load.
    If I redirect instead of import it works, but as I said I need to hide the url from the user as security is an issue.
    Any help appreciated, really pulling my hair out with this final stage of something that will make a real difference to us!
    regards,
    G.

    Thanks for the answer but Im afraid thicko here doesnt get it.
    The img src is relative to the sub page, and I have tried it with an absolute address (ie. http://localhost/.....) with the same result.
    If I call the sub page direct (get with browser) the image tag works. Its just if the sub page is imported with the jstl core import tag.
    I've not tried a base tag. The real project always returns pages containing absolute urls... http://ourReportServer/reports?....plenty of params so dont belive relevant, please correct me if Im wrong here though.
    thanks, G.

  • Fmt:message returns question marks instead of unicode

    well, pretty simple problem.
    When i'm using <fmt:message key="someunicode"/>, the tag returns question marks instead of hebrew unicode string.
    The page displays unicode that isn't coming from the tags.
    The resorues files is ok too.
    Anyone knows something about it?

    Have you set the bundle for the fmt tag before you use the <fmt:message> tag?
    <fmt:setBundle var="mybundle" basename="resources.application"/>
    Then :
    <fmt:message key="my.key.message" bundle="${mybundle}"/>You can also the the bundle in the <fmt:message> tag.

  • ClassCastException: javax.servlet.jsp.jstl.fmt.LocalizationContext

    today i had the following exception, which blows my mind away. what can be wrong?
    java.lang.ClassCastException: javax.servlet.jsp.jstl.fmt.LocalizationContext
         at org.apache.taglibs.standard.tag.common.fmt.BundleSupport.getLocalizationContext(Ljavax.servlet.jsp.PageContext;)Ljavax.servlet.jsp.jstl.fmt.LocalizationContext;(BundleSupport.java:127)
         at org.apache.taglibs.standard.tag.common.fmt.MessageSupport.doEndTag()I(MessageSupport.java:152)
         at jsp_servlet._web_45_inf._jsp._templates.__template._jspService(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(__template.java:235)environment: weblogic 8.1-sp4, jstl 1.0.6

    well the fact is that the JSPs are 100% correct. i'm migrating some legacy project, which builds, deploys and runs in its old state with no errors at all (and the old state is current PRO, so every bit of code is supposed to be correct). hence i presume it's not the JSPs that are wrong (because i never touched them), that's something else, probably the configuration of things, or conflicts between container libs and webapp libs, or sort of like that.
    so if this error doesn't ring a bell, then i'll try to fiddle around, i thought maybe that's something "famous" :).

  • JSTL fmt-localization

    Hello,
    I'm using Tomcat 5.5 as servlet provider and Apache 2 as proxy.
    My problem is that localization doesn't work.
    1. Choose locale -> Locale ok
    2. Choose another locale -> Locale ok
    3. Choose locale 1 -> locale still 2
    Order does not matter, second locale is used always, even if i change browser.
    jsp-code:
    <fmt:setLocale value="${requestScope.user_locale}"/>
    <fmt:bundle basename="messages">
    <fmt:message key="start.title"/>web.xml:
    <taglib>
                <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
                <taglib-location>/WEB-INF/fmt.tld</taglib-location>
         </taglib>     I print the value of requestScope.user_locale to page and it's ok. fi_FI or sv_SE
    I need help, please? :)

    Thank you for asking the right questions... i think :)
    le
    I'm changing with:
    <fmt:setLocale value="${requestScope.user_locale}"/>
    Cache is disabled:
    <%
    response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
    response.setHeader("Pragma","no-cache"); //HTTP 1.0
    response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
    %>
    requestScope.user_locale value is: fi_FI or sv_SE , it's Locale object (i'v printed it before fmt:setLocale
    ${javax.servlet.jsp.jstl.fmt.locale} does not print anything :(
    I do not know the version of JSTL, sorry :(
    web.xml is Servlet 2.3
    Thanks!

  • Issue with JSTL ( c:import ) tags in Weblogic 9.2

    Hi,
    I'm trying to migrate a struts (1.2.9) application from Weblogic 8.1 to Weblogic 9.2. This application has JSPs with JSTL (1.0) tags.
    I have a JSP page that has multiple (around 7) c:import statements. When I launch my application, only the content from the last c:import statement is being displayed and rest of the c:import tags statements is simply ignored by Weblogic.
    I don't find any errors in the logs. When I comment out last c:import statement in this JSP then the content from the above c:import statement is being displayed. Only one (last one) c:import statement's content is being displayed in that whole page.
    This app worked just fine Weblogic 8.1.
    Any resolutions, hints, insights or workarounds on this issue is appreciated.
    Thanks in advance,
    Mani
    Edited by: mayyalas on Aug 10, 2009 6:13 PM

    Hello,
    You should not need to edit the wlp-light-web-lib.war weblogic.xml file. There are many places where other classes in wlp-light-web-lib are dynamically loading classes (using Class.forName()) from "higher-level" shared library modules (such as wlp-framework-full-web-lib), so I am certain that it works in general. There may just be an issue with how your shared library is set up, or how your webapp deployment descriptors are set up.
    So you mention that you have a shared library module containing your implementation of the AnalyticEventHandler; is this a .war file? And in the webapp you are trying to deploy this in, does your weblogic.xml explicitly include your shared library? If so, is your shared library being included before or after the standard WLP shared libraries?
    If you would like, posting your webapp's weblogic.xml may help to find the problem.
    Kevin

  • Parsing & handling of object and param tags

    Hi all,
    I'm working on allowing people to paste certain embedded video code into a wysiwyg / html editor we've built with the help of (amongst others) javax.swing.text.html.HTMLWriter.
    I'm facing the following problem here:
    When i try to parse the <object><param></param></object> piece, it removes the <param> tags, and incorporates these in the <object> tag. For example:
    <object width="300" height="250"><param name="allowscriptaccess" value="always"></param></object>becomes:
    <object width="300" height="250" allowScriptAccess="always"></object>All param tags get converted into the object tag as String attributes. Problem with this is that the allowScriptAccess attribute is not a valid attribute of the object tag.
    Is there any way to prevent this conversion so it will retain the <param> tags?
    Thank you in advance.
    Edited by: Floxxx on Dec 28, 2009 10:16 AM

    This seems to be default behaviour in HTMLWriter, function Write().
    There it retrieves all elements with their attributes. The attributes summed up in the param tags show up as attributes for the object tag.
    Edited by: Floxxx on Dec 28, 2009 10:54 AM

  • SSI PARAM tag

    We are trying to implement server side includes for our servlets, but are
              having difficulty retrieving parameters passed using the param tag. Our
              shtml code is as follows:
              <HTML>
              <BODY>
              <SERVLET NAME=NavigationServlet>
              <PARAM NAME=Path VALUE=Job>
              </SERVLET>
              </BODY>
              </HTML>
              Inside the servlet, we run the following code to try to retrieve the value
              of "Path":
              String path = req.getParameter("Path");
              This returns null. If we try to pass the path as part of the URL
              (http://hostname/weblogic/test.shtml?Job=Path), the above statement is able
              to retrieve it; it only fails when passed in the <PARAM> tag on the .shtml
              page. Any ideas?
              Dave
              

    Yup! We're experiencing the exact same problem here! The only diff is our
              page code is in a .html file, and we direct *.html to SSIServlet. Here's
              the kicker: We have been doing this all through WL 4.5.1, and it WORKED
              THEN! The <PARAM> tag stopped working as of 5.1 upgrade! (Or perhaps it
              has something to do with JSDK 2.2 upgrade from 2.1, which we did
              concurrently with 5.1 upgrade)
              What's going on, and what's the solution, other than appending all our param
              name-values to the end of the servlet alias tag???
              Gene
              "David Salpeter" <[email protected]> wrote in message
              news:01bfa3bb$029b3080$4dea7bcf@7926CY570369...
              > We are trying to implement server side includes for our servlets, but are
              > having difficulty retrieving parameters passed using the param tag. Our
              > shtml code is as follows:
              >
              > <HTML>
              > <BODY>
              > <SERVLET NAME=NavigationServlet>
              > <PARAM NAME=Path VALUE=Job>
              > </SERVLET>
              > </BODY>
              > </HTML>
              >
              > Inside the servlet, we run the following code to try to retrieve the value
              > of "Path":
              >
              > String path = req.getParameter("Path");
              >
              > This returns null. If we try to pass the path as part of the URL
              > (http://hostname/weblogic/test.shtml?Job=Path), the above statement is
              able
              > to retrieve it; it only fails when passed in the <PARAM> tag on the .shtml
              > page. Any ideas?
              >
              > Dave
              

Maybe you are looking for

  • Using spool in a procedure

    Hi, I've a package with 6 procedures. In one procedure I need to load the data into a flat file. The procedure contains only one select statement. example: procedure pro_test as select * from emp; end pro_test; Shell script is being used to call one

  • Can we join Multiple Databases tables in PRD File ?

    Hi , I am working on POC project and trying to Join Multiple Databases to create one rpd file . Lets say I have complete SH schema from Oracle and I want couple of tables (Time and Products) tables from Sybase . I want bring sybase TIME and Product t

  • Problem: do something, if jumping in another textfield through tab-key

    hi, please, maybe can anybody help me..... I've got some textfields (JTextField) in a swing-application. by jumping in another textfield through pressing the tab-key, something should happen. I wrote the following code, but it doesn't works ;-( textf

  • How can one place a single image on a spread? CS3-MAC

    Hi all, i How can one place a single image on a spread? CS3-MAC A very straight forward question I think. I just never did it before. Anyone knows of a fast technique of doing this? I have to make 70+ images this way. Could it be scripted? thanx in a

  • Load error in FDM

    Has anyone ever gotten a data load error message when performing the export step in FDM? Once I load my data, I get a two line error file that says data load started and data load completed, but is an error file. My file loads, but I cannot get a gol