Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JSP and the fly likes problem in displaying dropdown menu items in jsp with jstl Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "problem in displaying dropdown menu items in jsp with jstl" Watch "problem in displaying dropdown menu items in jsp with jstl" New topic
Author

problem in displaying dropdown menu items in jsp with jstl

ganesh pol
Ranch Hand

Joined: Apr 29, 2005
Posts: 151
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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
ganesh pol
Ranch Hand

Joined: Apr 29, 2005
Posts: 151
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

Joined: Apr 29, 2005
Posts: 151
Please help meto solve this problem
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

What container and version? What is the declaration at the top of your web.xml?
sushma sree
Greenhorn

Joined: Mar 27, 2006
Posts: 12
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

Joined: Apr 29, 2005
Posts: 151
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

Your web.xml declaration is wrong. In order to enable the EL outside of the JSTL tags (like <cut>) you must declare your web.xml using the Servets 2.4 XML Schema.

See the JSP FAQ for details.
srilatha kareddy
Ranch Hand

Joined: Jan 12, 2006
Posts: 32
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

Joined: Jan 12, 2006
Posts: 32
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

Joined: Apr 29, 2005
Posts: 151
Thanks
Bear Bibeault and srilatha kareddy

i follow as u said and now it works fine and it displays correct values
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in displaying dropdown menu items in jsp with jstl
 
Similar Threads
Problems making Struts/JSTL 1.2 site work with JSTL 2.0
The absolute uri problem
getting "No tag "forEach" defined in tag library imported with prefix "c" "
Versions of JSTL and EL on a legacy project
problem with tld file