Solved

struts: how can the list being retrieved from new window

Posted on 2006-07-24
13
663 Views
Last Modified: 2010-04-01
xxxaction.java already set the list such that session.setAttribute("xxxlist", list). How can the list being retrieved from new window opened by javascipt newwin? Using <logic:iterate> to retrieve the list get null pointer exception.
0
Comment
Question by:jeff1919
  • 5
  • 5
13 Comments
 
LVL 6

Expert Comment

by:Holger101497
ID: 17167096
We need some more information:

Does your <logic:iterate> work in the main window?

Do both windows use the same session? (i.e. if you're not using cookies, you have to pass the session in the URL, for example).
Just try "session.getAttribute("xxxlist")" in the new JavaScript window and see it it's really there!

Other than that, there should be no problem printing the list in a popup window if it's stored in the session and not the request...
0
 
LVL 29

Accepted Solution

by:
bloodredsun earned 250 total points
ID: 17171045
Use JSTL not the logic libs as this is what is recommended by the struts developers.

It would be this:

<c:forEach var="myitem" items="${sessionScope.xxxlist}">
    <c:out value="${myitem}"/>
</c:forEach>

As long as the value exists, it will be displayed.
0
 

Author Comment

by:jeff1919
ID: 17172869
session.getAttribute("xxxlist") also returns null in new window. Had no problem retrieved the data from the list in main window.

jstl is not allowed to use.  
0
 
LVL 6

Assisted Solution

by:Holger101497
Holger101497 earned 250 total points
ID: 17172898
well... it seems like you're losing your session then. Do all your other links contain a session parameter? If so, you might need to use response.encodeURL(sUrl) to pass the session to the popup-window...

If you're using (session) cookies, the popup window must be on the exact same domain to receive the cookie. What is the exact URL of the calling page (please post if possible) and what is the exact URL (including full domain) of the popup-window? (please check with the "page information"; depending on which browser you're using).

Even for something silly like the main page on "localhost" and the popup on "127.0.0.1", you will lose the session information.

ok, I have to go to bed now! I'll check back later... Good luck :-)
0
 

Author Comment

by:jeff1919
ID: 17177634
i have found new window contains different session id. Response.encodeURL returns the same url without attached session id on it. (ps: url = popupxxx.jsp)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Expert Comment

by:Holger101497
ID: 17178361
So we're getting closer to the real problem :-)

Can you show us the command that creates the popup-code and the generated page source for the popup?
Also: What is the URL of the calling page (as displayed in your browser), do you use "<base href='...'>" in your page and what is the URL of the popup?
0
 

Author Comment

by:jeff1919
ID: 17180827
The following is the code calling the popup window.

<td width=100 height=20 class="font1" style="border-top:solid #336699 .5pt;border-bottom:solid #336699 .5pt;border-left:solid #336699 .5pt;border-right:solid #336699 .5pt;" bgcolor=Gold align=center><a href="#" onclick="javascript:newwin=window.open('emlprint.jsp','h','width=300px,height=300px;')" onMouseOver="window.status='Print';return true;" onMouseOut="window.status='';return true;" style="font-size:8pt">Print</a></td>
      
the list to be iterated is set in action class...the page contains above code can show the list correctly...that is, the list is not null before open the new window...
0
 
LVL 6

Expert Comment

by:Holger101497
ID: 17180883
Pleeeeeeaaaase - I can not help you if you don't answer my question!

> What is the URL of the calling page (as displayed in your browser), do you use "<base href='...'>" in your page and what is the URL of the popup?

I've asked this twice already and it's VERY important!!!
Please check the URLs of the two pages from the browser "page information"...

> that is, the list is not null before open the new window...

well, it's not null after the new window opens either - but it is stored in the session and for some reason (probably related to cookies and domains), the popup has a different session and THAT session does (of course) NOT contain a list...

P.S.: never heard of CSS classes? The css code attached to a td looks horrible!
0
 

Author Comment

by:jeff1919
ID: 17180963
The url for calling page is...http://localhost:9080/MasterList/control.do and the url for pop window is not shown in the browser. The code generates the pop up window is <a href="#" onclick="javascript:newwin=window.open('emlprint.jsp','h','width=300px,height=300px;')" But I don't think url information is useful.

PS:  i am not the one writing the css code.
0
 

Author Comment

by:jeff1919
ID: 17181000
the pop up window has different session and that session does not contain the list. if the list is called in that session, we get null exception. it's possible the list is null and cause the null exception. I just tried to eliminate this possiblity..  
0
 
LVL 6

Expert Comment

by:Holger101497
ID: 17181927
I'm a little bit confused by your last post...  (language problems...): Do you mean the popup window is SUPPOSED to have a different session? You mean you want it that way? If so, let me know.

If not, PLEASE post the URL of the popup - you can get it from the window properties in the popup (which browser are you using?), even if there is no address bar.

One more shot in that direction:
You said you can display the list in the main window. Do that. And then change the address in the main window from http://localhost:9080/MasterList/control.do to http://localhost:9080/MasterList/emlprint.jsp

Let me know what happens...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Cloud-based technologies and services will continue to grow in popularity in 2017 thanks to the simple, scalable and cost-effective solutions they deliver. Here are three areas where cloud adoption is poised to really take off.
: Microsoft Office Collaborate for free and online versions of Microsoft  Word, Excel, Powerpoint, OneNote, Onedrive , Email, Calendar etc. In short we can say that Microsoft office is a suite of servers, applications and services developed by  Micr…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now