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
Programmer Analyst || J2EE web development/design
Shailesh Narkhede
Ranch Hand
Joined: Jul 10, 2008
Posts: 356
posted
0
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)
Thanks,
Shailesh
Shashank Rudra
Ranch Hand
Joined: Mar 26, 2009
Posts: 131
posted
0
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
Joined: Jul 10, 2008
Posts: 356
posted
0
Which JSP version you are using?
Which container you are using?
Shashank Rudra
Ranch Hand
Joined: Mar 26, 2009
Posts: 131
posted
0
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
Joined: Jul 10, 2008
Posts: 356
posted
0
Are you included jstl.jar & standard.jar in your web all lib directory?
That is needed for JSTL.
Shailesh Narkhede
Ranch Hand
Joined: Jul 10, 2008
Posts: 356
posted
0
Please check THIS link.
Here you get information regarding configuration for JSTL usage.
Shashank Rudra
Ranch Hand
Joined: Mar 26, 2009
Posts: 131
posted
0
not needed so deleted
Shailesh Narkhede
Ranch Hand
Joined: Jul 10, 2008
Posts: 356
posted
0
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.
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
Joined: Jul 10, 2008
Posts: 356
posted
0
For spacification you ask to container vendor for which JSP version it is supporting.
Shashank Rudra
Ranch Hand
Joined: Mar 26, 2009
Posts: 131
posted
0
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
Joined: Jul 10, 2008
Posts: 356
posted
0
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
Joined: Mar 26, 2009
Posts: 131
posted
0
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.
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
Joined: Mar 26, 2009
Posts: 131
posted
0
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 cut - 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.
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.