Solved

HTTPRequest.setAttribute() question

Posted on 2000-03-02
9
277 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
Comment Utility
I am not sure if you implement the interface java.io.serializable for your class(or object).
0
 
LVL 5

Expert Comment

by:fontaine
Comment Utility
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
Comment Utility
0
 
LVL 4

Author Comment

by:jerch
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 16

Expert Comment

by:heyhey_
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
thanx heyhey
0
 
LVL 16

Expert Comment

by:heyhey_
Comment Utility
Thank you :)
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
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:

728 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

11 Experts available now in Live!

Get 1:1 Help Now