• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to print variable request parameters in el?

 
Kumar Jaya
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a beginner in el and jstl. I have a jsp that has the scriptlet


I want to print the values using el. I tried this but it gives JasperException in Tomcat


I dont know what is wrong, when I print name_${i} i am getting the attribute name but passing that name to the el expression does not seem to work? printing ${name_i} within the loop also fails?
 
Vijitha Kumara
Bartender
Posts: 3952
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't have "items" attribute to iterate over? Check the API
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't nest one EL expression within another.

Hint 1: use <c:set> to perform string concatenation to create the variable name; then use the EL expression.

Hint 2: why are you doing something so convoluted in the first place? Figure out a simpler way to accomplish the same with better variable names or constructs.
 
Stefan Evans
Bartender
Posts: 1822
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two other bits of information you need to know
1 - square brackets notation
2 - the 'requestScope' implicit variable which is a map of attributes in the request.

 
Kumar Jaya
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:You can't nest one EL expression within another.

Hint 1: use <c:set> to perform string concatenation to create the variable name; then use the EL expression.

Hint 2: why are you doing something so convoluted in the first place? Figure out a simpler way to accomplish the same with better variable names or constructs.


I am trying to learn el and jstl. I am always having problems with el, I really do not understand how they work, they are bit different from java variables and constructs!
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You wouldn't try to create Java variables by concatenating a real variable name with a series of numbers, either. People who ask about that in the Beginning Java forum are told to use arrays or a map. It's true that EL isn't the same as Java, but you seem to be trying to learn it by guesswork. I would suggest you find some JSTL and EL tutorials and read through them. Find some real JSTL code to look at.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!