• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

c:set and scope

 
J Haley
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between the two items below?



I thought that test1 would be available to me once I posted to my servlet. It's not so it seems to me that test1 and test2 above behave the same. What am I missing?

Jay
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Attributes in request scope are available to any jsp page or servlet that are part of the specific request chain. For instance, if I made a GET request to servlet1, which forwarded to servlet2, which forwarded to jsp3, etc... attributes put in request scope in servlet1 would be available in jsp3 as well.

Attributes in page scope are accessible only within the specific JSP page and is destroyed when the page has finished generating its output for the request. Page scope is usually used with custom tags, and it is a way to pass data from the jsp page to the custom tag.
 
J Haley
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had that same understanding as what you described, that�s why I�m confused.

I have the following code in a jsp that submits to a struts action.



Since scope is set to request, I would expect that I would have a handle to �test1� by using request.getAttribute(�test1�); in my action that I�m posting to. I don�t and that�s what I don�t understand.

Jay
 
geeta lalchandani
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u will get it using request.getParameter instead of getAttribute
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic