This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes enum in JSP EL & 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 "enum in JSP EL & JSTL" Watch "enum in JSP EL & JSTL" New topic
Author

enum in JSP EL & JSTL

Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
Hi All,

I want to use enum in jsp using EL & JSTL, below is code,



above code OWN is hardcoded string in EL,
Instead of using hardcoded string want to use a enum PaymentOerationType having all possible values of payment type.
I am not able to use PaymentOerationType.OWN directly in EL.

How can I deal with emuns in EL or JSTL?

Thanks,
Shailesh
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

You cannot directly access the enum. What you can dois to use the values() method of the enum to gather the enum values into a Map or List and use it on the page by placing it in request scope.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
Hi Bear,

Thanks for reply.

It worked way you told, but just one question in my mind why EL or JSTL does not support a enum?

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

Dunno. They didn't consult me during the specification phase.
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
:) I was thinking might be some technical reason for that you might know.
anyways thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: enum in JSP EL & JSTL
 
Similar Threads
Enums in JSPs
How can I consolidate some duplicate JSTL code in my JSP?
JSP Struts/JSTL Form problem
Help in JSTL And EL
JSTL doubts (c:if)