Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

problem in displaying dropdown menu items in jsp with jstl

 
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
see my controller code


protected Map referenceData(HttpServletRequest request){
Map refDataMap=new HashMap();
IEmsDelegator delegator = (IEmsDelegator) getDelegator(BeanConstants.EMS_DELEGATOR);
List expenseTypeList=delegator.getExpenseTypes();
refDataMap.put(EmsConstants.EXPENSE_TYPES_LIST,expenseTypeList);
return refDataMap;
}



where
EmsConstants.EXPENSE_TYPES_LIST is
public static final String EXPENSE_TYPES_LIST="expTypes";


and part of jsp relevent to this topic is

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<%@ taglib prefix="spring" uri="/spring"%>
<HTML>

.
.
.
.
..

<SELECTsize="1" >
<OPTION value="-1">
SELECT...
</OPTION>
<c:forEach items="${expTypes}" var="expenseType">
<option value="${expenseType.expenseTypeId}">${expenseType.expenseTypeName}</option> </c:forEach>
</SELECT>



part of tld file

<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">

<description>JSTL 1.1 core library</description>
<display-name>JSTL core</display-name>
<tlib-version>1.1</tlib-version>
<short-name>c</short-name>
<uri>http://java.sun.com/jsp/jstl/core</uri>;


my problem
when i want to render the jsp page my page does not render actual o/p

but gives ${expenseType.expenseTypeName}


please help to solve this problem
 
Sheriff
Posts: 67618
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If EL expressions are not being evaluated, you may have a set up problem. See the JSP FAQ for information on properly setting up a JSP 2.0 web application.
 
ganesh pol
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear Bibeault

i face roblem only in displaying dropdown menu

but my normal

<inputtype="text"
name="<c ut value="${status.expression}"/>"
value="<c ut value="${status.value}"/>"

tag works fine and does not have any problem

i face only problem in dropdoown menu
 
ganesh pol
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help meto solve this problem
 
Bear Bibeault
Sheriff
Posts: 67618
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What container and version? What is the declaration at the top of your web.xml?
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you check to see if your list is getting populated? And also is the forEach getting executed? I mean if you give something like this, is it working?

<c:forEach items="${expTypes}" var="expenseType">
Hello
</c:forEach>
 
ganesh pol
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for taking time for me



first reply to Bear Bibeault

i am testing this application on both

jboss-4.0.2 and Apache Tomcat 5.0


declaration at the top of my web.xml is

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<!--##################taglibs used in the application#######################-->
<taglib>
<taglib-uri>/spring</taglib-uri>
<taglib-location>/WEB-INF/tld/spring.tld</taglib-location>
</taglib>

<taglib>
<!-- <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>-->;
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>;
<taglib-location>/WEB-INF/tld/c.tld</taglib-location>
</taglib>




part of my c.tld file is

<?xml version="1.0" encoding="UTF-8" ?>

<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">

<description>JSTL 1.1 core library</description>
<display-name>JSTL core</display-name>
<tlib-version>1.1</tlib-version>
<short-name>c</short-name>
<uri>http://java.sun.com/jsp/jstl/core</uri>;






now reply to sushma sree

my List contains 4 record of Expense Type

as u said i tried
and it gives me 4 hello printed on my jsp page

it will be great help to me if anyone solve this issue
[ April 04, 2006: Message edited by: ganesh pol ]
 
Bear Bibeault
Sheriff
Posts: 67618
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your web.xml declaration is wrong. In order to enable the EL outside of the JSTL tags (like <c:out>) you must declare your web.xml using the Servets 2.4 XML Schema.

See the JSP FAQ for details.
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
bear is right
you have to use

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
 
srilatha kareddy
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
one more thing

is map is set as attribute

pageContext.setAttribute("map", yourmap);

see The JSTL Expression Language > Common Mistakes
http://www.phptr.com/articles/article.asp?p=30946&seqNum=10&rl=1
 
ganesh pol
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
Bear Bibeault and srilatha kareddy

i follow as u said and now it works fine and it displays correct values
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic