• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How get variable from list?

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello people,

i have stupid problem - how can I get variable from list?

In list ( conferenceList ) is variable idConference and I need work with it. But I can't do it. I tried to use <%= %>, %{}, etc.

Here is my code:


Thanks
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't use OGNL notation ( i.e. "%{}") inside a scriptlet. You would need to access the request and get the value stack. The first value on the stack would be the current value of the iterator.
Best Practices for JSP's tell us to avoid using scriptlets. If you need to "work with" a value, do it in your action or a business logic bean. Leave JSP's for display logic.
 
Honzak Troubak
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply!

You were right, I had to use HttpServletRequest.



Only one small question - I have problem on line 7: <s:property value="conferenceList[<%=cislo%>].title"/>

When I use number, for example <s:property value="conferenceList[0].title"/> , everything is all right.

But when I use <%=cislo%> it doesn't work. I think it's similar problem like in my first question but unfortunately I can't resolve it.
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again, you should not be using scriptlets (java code inside a JSP). If all you need is an ID inside a URL, Struts provides a url tag that lets you construct a URL with parameters.
 
reply
    Bookmark Topic Watch Topic
  • New Topic