• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Replace scriptlet

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

<%
List list = new ArrayList();
list.add("Abc");
list.add("Xyz");
%>

Please help me in replacing the scriptlet with standard actions and EL...

Kumaraguru
 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hint: use [] operator of EL
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Is it possible to add elements to a List using [] operator of EL? If so please clarify how.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kumaraguru Narayanan wrote:
<%
List list = new ArrayList();
list.add("Abc");
list.add("Xyz");
%>
Please help me in replacing the scriptlet with standard actions and EL...




Hi Kumaraguru,

first of all, dont do business logic in jsp. setting the datas in a list should come in java class or servlet . then set the list into the session|request scope and forward it to your success jsp page. then for displaying the data use jstl|EL .

Hope this helps
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hint: use [] operator of EL


Do you think it will work ? Basically, EL is used to read data.
 
Sheriff
Posts: 67750
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

seetharaman venkatasamy wrote:first of all, dont do business logic in jsp.



Yes. Here is the crux of the matter. The purpose of the JSTL and EL isn't just to replace scriptlets with a different syntax to do inappropriate things on a page, it's to urge (even force) people to design or refactor their web apps using modern best practices.

When replacing scriptlets with JSTL/EL there isn't always a one-to-one correspondence -- and there shouldn't be! It's an opportunity to evaluate what you are doing on your JSP and decide if it is appropriate or not, and if not, refactor.

If you can't do something on your page easily with the JSTL and EL, chances are it's because of a design flaw.
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
EL is for expression, not for business procession.

Consider to put business logic in Servlet or POJO.
 
Everybody's invited. Even this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic