Solved

HTTPRequest.setAttribute() question

Posted on 2000-03-02
9
317 Views
Last Modified: 2013-11-24
My JSP generates a page which contains a frameset.  The frameset has two sources which are both jsp.  My question is how do I pass objects from the jsp, that generates frameset, to the two jsp sources using the setAttribute method of the HTTPRequest.


By the way, I'm employing the model view controller design pattern.

Thanx in advance.

Jerson
0
Comment
Question by:jerch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 

Expert Comment

by:cutewang
ID: 2575672
I am not sure if you implement the interface java.io.serializable for your class(or object).
0
 
LVL 5

Expert Comment

by:fontaine
ID: 2575988
You should actually work with a Session. In the JSP generating the frameset, you will have:

// create a session
HttpSession session = request.getSession(true);

// store the object in the session
// here, a date, stored under the "date"
// key
session.putValue("date", new Date());

To collect the Date object from the other JSPs, you write:

// get the session
HttpSession session = request.getSession();

// get the date
Date date = (Date)session.getValue("date");

Tell me if this is an answer.
0
 
LVL 7

Expert Comment

by:vladi21
ID: 2576011
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:jerch
ID: 2576118
I have considered using session but the data I'm want to pass is only within the scope of a request. For example, the data I'm passing is a list of results from a query.  What if the user has multiple windows.  If I use session, the data will be mixed up, which means the other window will the result of the other query instead of its own. Actually, the session solution is what we used in our previous project but we found out that there's this limitation for multiple windows.  
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 2579076
browser send sends one HTTP request for main page and one HTTP request for each Frame (which is just anothe HTML document). so you can't use setAttribute (different requests) - the only possible solution is to use session. (or you can redesign your UI with tables - Frames sucks :)
0
 
LVL 4

Author Comment

by:jerch
ID: 2579410
heyhey...
do you know any design alternative without changing the ui?  I'm planning to use a unique id to identify which object to get in the session.

<frame name="wmailmenu" src="http://site.com/jsp/myjsp.jsp?id=<generated for a specific piece of data>>

Do you think this is a good solution?  By the way, what should be the method type of the jsp (post or get?)

thanx in advance....

0
 
LVL 16

Accepted Solution

by:
heyhey_ earned 100 total points
ID: 2579846
this is the only alternative (in fact it works almost the same was as web sessions with 'URL rewriting') - and yes - it's good solution.
the request type is GET.

0
 
LVL 4

Author Comment

by:jerch
ID: 2580083
thanx heyhey
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 2580508
Thank you :)
0

Featured Post

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

691 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