in Eltest.jsp code1: <c:forEach var="arr" items="${matharry}" > <c ut value="${arr}"/> </c:forEach>
or code 2: <c:forEach var="arr" items="${requestScope[matharry]}" > <c ut value="${arr}"/> </c:forEach>
my output: blank page
If i uncomment RequestDispatcher then only code 1 works if i commet RequestDispatcher i know the code 1 wont work but code 2 is not working in either case
Thanks inadvance Sravanthi
[ May 02, 2008: Message edited by: Vijaya Sravanthi ] [ May 02, 2008: Message edited by: Vijaya Sravanthi ]
al langley
Ranch Hand
Joined: Mar 28, 2008
Posts: 35
posted
0
Is the jsp code you have code for Eltest.jsp?
Also, not sure if this is right, but I think your problem might have to do with the fact that request scope attributes are valid for only one request. So if this is right (and I am not sure if it is), by the time you get to your jsp code, the attributes are already gone. [ May 02, 2008: Message edited by: al langley ]
S Sravs
Ranch Hand
Joined: Feb 25, 2008
Posts: 85
posted
0
thanks langley you have been helping me actually when i am reading about EL implicit scopes which are used to get the attributes set in request object of servlet can be retrived using requestScope implicit object but i didnt get expected output [ May 02, 2008: Message edited by: Vijaya Sravanthi ]
al langley
Ranch Hand
Joined: Mar 28, 2008
Posts: 35
posted
0
What output did you get in your second code? You may want to try and put single quotes around 'matharry' and see if that works. For example: "${requestScope['matharry']}"
S Sravs
Ranch Hand
Joined: Feb 25, 2008
Posts: 85
posted
0
that works finally i would like to know more differences between [],[''],[""]
i have tried code 2 replacing requestScope[matharry] with requestScope.matharry it is working
Shiraz Khan
Ranch Hand
Joined: Mar 20, 2006
Posts: 51
posted
0
while using EL, we dont have to worry about the scope of the attribute unless there is a naming conflict between scopes (HFSJ page 385)
I dont get why the first code is not printing the value ?? Can anybody put some light on this !!
I think we will get the results if we use this ..
<c ut value="${matharry[0]}"> <c ut value="${matharry[1]}"> <c ut value="${matharry[2]}"> <c ut value="${matharry[3]}"> [ May 04, 2008: Message edited by: Shiraz Khan ]
Musab Al-Rawi
Ranch Hand
Joined: Aug 06, 2007
Posts: 231
posted
0
Khan,
As you can see the attribute is being set in a servlet while the printing is done in a JSP. the RequestDispatcher will pass the request (and its attributes) and the reponse to the JSP. That's will allow the matharry to exist in the JSP, without the request dipatching and forwarding matharry doesn't exist in the JSP and it will be null.