Solved

HTTPRequest.setAttribute() question

Posted on 2000-03-02
9
292 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
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Weekend adv creator 3 36
session migration servlets 2 35
tomcat not starting 6 45
Adding multiple JVM environments to RedHat 6 7 17
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 first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This video teaches viewers about errors in exception handling.

816 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

10 Experts available now in Live!

Get 1:1 Help Now