• 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

Couple of questions on JSP

 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi i wanted to know how you could create an arraylists on a JSP without using scriptlets.
I actually wanted to do something like this but without using Scriptlets..



so the questions are
1)Request is an implicit object passed to a jsp how could i set a value in the request object using EL ?
2)Can i create an arraylist using JSTL ?? Any hint , example would be appreciated
3) How would i accomplish this using JSTL (does that make sense) or without scriptlets?
RequestDispatcher view=request.getRequestDispatcher("test");
view.forward(request, response);


 
Sheriff
Posts: 67746
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

Rajesh Khan wrote:Hi i wanted to know how you could create an arraylists on a JSP without using scriptlets.


You can't and you shouldn't.

JSPs for for generating the view. Any such structures should be created prior to forwarding to the JSP in its controller.

If for some rare reason the creation must take place under control of the JSP, then a custom tag or EL function can be used.
 
Bear Bibeault
Sheriff
Posts: 67746
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

Rajesh Khan wrote:
1)Request is an implicit object passed to a jsp how could i set a value in the request object using EL ?


The request is available in the pageContext.

2)Can i create an arraylist using JSTL ?? Any hint , example would be appreciated


No, see above reply. There are lots of things that aren't easy to do in a JSP by design because you shouldn't be doing those sorts of things there.

3) How would i accomplish this using JSTL (does that make sense) or without scriptlets?


There's a JSP action for that -- but note that it's rare to have to forward from a JSP and it's almost always a red flag that your design is likely flawed.
 
Ranch Hand
Posts: 98
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
you can set array list in request as attribute and iterate it in it forwarded jsp using EL.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic