?
Solved

HTTPRequest.setAttribute() question

Posted on 2000-03-02
9
Medium Priority
?
323 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 400 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

Technology Partners: 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!

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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 one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
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.
Suggested Courses
Course of the Month14 days, 16 hours left to enroll

839 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