Announcement Announcement Module
No announcement yet.
Jstl cannot resolve map variable Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Jstl cannot resolve map variable

    Please who has solution to this problem.

    org.apache.jasper.JasperException: Unable to find a value for "COUNTRYCODE" in object of class "java.lang.String" using operator "."
    org.apache.jasper.servlet.JspServletWrapper.handle JspException(
    org.apache.jasper.servlet.JspServletWrapper.servic e(
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    org.springframework.web.servlet.view.InternalResou rceView.renderMergedOutputModel(InternalResourceVi
    org.springframework.web.servlet.view.AbstractView. render(
    org.springframework.web.servlet.DispatcherServlet. render(
    org.springframework.web.servlet.DispatcherServlet. doDispatch(
    org.springframework.web.servlet.DispatcherServlet. doService(
    org.springframework.web.servlet.FrameworkServlet.s erviceWrapper(
    org.springframework.web.servlet.FrameworkServlet.d oGet(
    javax.servlet.http.HttpServlet.service(HttpServlet .java:689)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

    The block of code that triggered the error is shown below:

    <tr class="row2">
    <td width="37%" align="right" nowrap><Strong><font face='century gothic' >Country</font></td>
    <td width="3%"></td>
    <td width="60%">
    <spring:bind path="contact.countryCode">
    <select name="countryCode" class="select">
    <option selected value="">(SELECT)${status.value}</option>
    <c:forEach items="${countries}" var="county">
    <option value="${county.COUNTRYCODE}" <c:if test="${status.value eq county}">selected</c:if>>${county.COUNTRYNAME}</option>
    <font color="red">${status.errorMessage}</font>

    countries is a list of map objects while county is a reference variable to the map objects in the list.
    Last edited by sundec19; Oct 10th, 2008, 04:06 AM. Reason: Typo graphical error

  • #2
    are you sure there is filed named "COUNTRYCODE" in county, and there also should be the setter and getter.


    • #3
      Jstl cannot resolve map variable

      Below is the refenceData method of the controller.

      protected Map referenceData(HttpServletRequest request) throws Exception {
      Map model = new HashMap();
      model.put("countries", listWriter.getCountries());
      return model;

      Also, below is the block of code that fetches contries data fron database.
      Please help!!!

      public List<Map> getCountries(){
      String query = "select country_code as countryCode, upper(country_description) as countryName from country order by country_description";
      return springDao.getResultMap(query);

      Below is the springDao referenced above:

      public List<Map> getResultMap(String query){;
      List<Map> lst= new ArrayList<Map>();


      lst = (List<Map>)getJdbcTemplate().queryForList(query);

      }catch(Exception exp){

      return lst;


      • #4
        Make sure your servlet container is 2.4+ - as this could be down to you not being able to use the expression language.

        Also, drop the spring bind tags if you're using spring 2.0+ and use the form taglibs.

        Lastly check your spelling as "county" should be "country"


        • #5
          Jstl cannot resolve map variable

          I'm using Tomcat 5.5.17 which is a Servlet 2.4+ compliant container.

          Using country as the variable didn't work as well.

          I'm using spring 1.2.9. Please if this is not a version of Spring 2.0+, help me with sample code of form taglibs.


          • #6
            do u have

            version="2.4" in your web.xml and have you used the expression language in other pages on your site?

            Regarding form taglib - u will need to upgrade your spring libs and then read