aspose file tools*
The moose likes JSP and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark ""Window scope"" Watch ""Window scope"" New topic
Author

"Window scope"

Jiri Nejedly
Ranch Hand

Joined: Oct 22, 2002
Posts: 81
I am writing web application (Spring MVC, ...). I need to pass some attribute (or parameter) into page creted in new window (codebook, table) and then pass the same attribute to every other page called from there (codebook, form). Little simplification - every new page is opened in the same window (javascript window.open(...)). The attribute should live as long as the window (codebook) lives. I need some "window scope".
Does exist some technique to do this? Thanks.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

In a stateless protocol, like HTTP, there is no way to tie any of the server side scoped objects to the length of time that a browser window is open.
If you need a server side object to live longer than the time that it takes to respond to an HTTP request you'll need to use either session or context (appication) scope.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Preeti Arora
Ranch Hand

Joined: Jan 26, 2007
Posts: 74
Probably you can try
window.opener.document.formname.fieldname.value

This value is from previous window which has opened the new window.
Make any variable in the new window and assign this value to it.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61418
    
  67

Originally posted by Preeti Arora:
Probably you can try ...


Which is rather klunky and can only work if the original opening page is never refreshed, or navigated away from , or the browser closed, and so on.

The session is a much better and safer place to store such values.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "Window scope"