• 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

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

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
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
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.
 
Bear Bibeault
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
P.S. Using the 'disable smilies' checkbox when posting code will make your tags look less bratty.
 
Nadine McKenzie
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
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

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?
 
It means our mission is in jeapordy! Quick, read this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic