• 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

using JSTL and EL to get/set request parameters

 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys

I am trying to set List as a request parameter in one JSP and then display the same list using EL on other JSP to which I am posting from the first JSP.

The first JSPHere I am setting the request parameter and then submitting to the testList.jsp where I am trying to access the List entries.
testList.jspBut this is getting me this error Please suggest what I need to do differently. TIA
 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you pasted whole jsps?
In testList.jsp we need to put taglib directive to use core jstl tag library.
(you are using c: forEach & c: out)
 
Shashank Rudra
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have edited the above post to include those parts that I had just left out. I further found that jar files were missing. So I added jstl-1.2.jar and javax.el.jar.

After this we need javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext. And this is in javaee.jar. When I am trying to add this jar in buildpath - it contains a servlet.class which is creating some conflict.

How to get rid of this.
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which JSP version you are using?
Which container you are using?
 
Shashank Rudra
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to see the JSP version? However the web.xml I am using has this DTD declaration Container is Tomcat5.0
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you included jstl.jar & standard.jar in your web all lib directory?
That is needed for JSTL.
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please check THIS link.
Here you get information regarding configuration for JSTL usage.
 
Shashank Rudra
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
not needed so deleted
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I have edited the above post to include those parts that I had just left out. I further found that jar files were missing. So I added jstl-1.2.jar and javax.el.jar.




Are you added jstl-1.2.jar this jar this is for JSP 2.1 (for tomcat 6).
Use jstl.jar with standard.jar you will info about that http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html
 
Shashank Rudra
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks buddy. Phew

Please check THIS link.
Here you get information regarding configuration for JSTL usage.

did the magic. Now only two jars jstl.jar and standard.jar are doing all the work. No need to go for other jars.

One more thing though- in the second jsp where I am trying to access the List is not working. Please tell me how to get it rite. Also how to know which JSP version I am using. Tomcat5.0 is JSP2.0 container that I just saw in the link but any other way to get at that piece.

 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For spacification you ask to container vendor for which JSP version it is supporting.
 
Shashank Rudra
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got you. It was really conceptual. But how to access the List set as request parameter and iterate through that. ?? Help me out.
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
there is no problem with forEach tag of JSTL.
But through scriptlet also we are not getting ArrayList in testList.jsp.
 
Shashank Rudra
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I did I shall be able to get the same attribute using get for the name "strList".

But when I am using in the scriptlets on debugging the file the strList here is coming null. Why is this happening. Has it to take with the serialization aspect of the List. May be List can not be set as attribute in the request. Then how else can we access the collections being returned from a servlet in a JSP page.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're posting a form, thus creating a new request: the current request's attributes aren't available in the new request.
 
Shashank Rudra
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very truly pointed out. I added these lines in the first JSP inside the form . This got me the result I was expecting i.e. on the second JSP I am able to access the List elements. Only thing is that while doing c:out - the entries are covered by '[' at the start and ']' at the end. I dun kno why?

Thank guys a lot. Without such an active help I would have once again left this exercise incomplete like before.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because you're not passing a list, you're passing the string representation of a list.

Forms submit strings--*always*.
 
Shashank Rudra
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any way to do as a List?

Here is the code for the above bracket appearance and their removal I bet there is a better way to do this. If any one knows that. TIA
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the list is being generated on the business side then either re-generate it, cache it, keep it static, or something. Or just keep it in the session if it's user-specific, or application context if it's app-wide.
 
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
"Giffy Geraldo", please check your private messages for an important administrative matter.
 
Shashank Rudra
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks David. That made perfect sense.

Bear, I have done that. Thank you.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic