aspose file tools*
The moose likes JSP and the fly likes JSTL Question about c:set  ... scope= Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL Question about c:set  ... scope="request"" Watch "JSTL Question about c:set  ... scope="request"" New topic
Author

JSTL Question about c:set ... scope="request"

Nadine McKenzie
Ranch Hand

Joined: Feb 15, 2002
Posts: 53
I have this code...
<logic resent name="results" scope="request">
<c:set var="resultsInRequest" scope="request" value="requestScope.results" />
</logic resent>
<logic resent name="search" scope="request">
<c:set var="searchInRequest" scope="request" value="requestScope.search"/>
</logic resent>

Since I'm setting my scope as request vs page, I would expect that when submitting this page that both resultsInRequest and searchInRequest could be retrieved from the HttpServletRequest request.getAttribute("searchInRequest").

Does anybody know what I'm doing wrong? ThanKs!


Nadine -SCJP, SCWCD, SCBCD
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61221
    
  66

This is a fundamental concept in HTTP. The request that you use to render a page and send it to the browser has nothing to do with the request that gets created when that page is submitted.

Anything that you put onto request scope goes bye-bye as soon as the response is sent to the browser.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61221
    
  66

P.S. Using the 'disable smilies' checkbox when posting code will make your tags look less bratty.
Nadine McKenzie
Ranch Hand

Joined: Feb 15, 2002
Posts: 53
This is what I thought. But it is logically obtuse. If it were set to "session" it would die when the session timesout. If it were "page" it would die when the page dies. It would have been better if setting the scope to "request" would behave as request.setAttribute. Oh well...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61221
    
  66

But it is logically obtuse.


Not at all. Request scope extends for the lifetime of the request. Page scope extends for the lifetime of a JSP page. Session scope extends for the lifetime of a session. And application scope extends for the lifetime of an application context.

What's obtuse about it?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL Question about c:set ... scope="request"