Solved

Null object

Posted on 2011-03-11
7
376 Views
Last Modified: 2013-12-17

Hi,

I'm developing a web application, where it has few stages to process an order. There is an object as paymentInfo from PaymentInfo class (in step 3) and I need to use it in step 4. How can I access paymentInfo object from the last phase (step 4)?

The problem is that when I declare an object such as:

PaymentInfo myobj = new PaymentInfo();

I see myobj has null value.

Any help is appreciated.

Regards,
ak





0
Comment
Question by:akohan
7 Comments
 
LVL 23

Expert Comment

by:wdosanjos
ID: 35111022
You should save the PaymentInfo object in the Session.  Something like this:

On Step 1:
PaymentInfo myobj = new PaymentInfo();
Session["PaymentInfo"] = myobj;

On the following steps:
PaymentInfo myobj = (PaymentInfo)Session["PaymentInfo"];


More info on Session:
http://msdn.microsoft.com/en-us/library/ms178581.aspx

I hope this helps.
0
 
LVL 7

Expert Comment

by:jdavistx
ID: 35111029
Not sure how your stages are setup, but it looks like you need to pass your object to the next phase.  You need to send myObj to the next phase using whatever mechanism starts phase 4.  Your myObj is null because you're initializing a brand new PaymentInfo object.
0
 

Author Comment

by:akohan
ID: 35111080

that is right but temporary I need to pass credit card info and saving it into session is not a safe way. Any comments on this?

Thanks.
0
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.

 
LVL 23

Accepted Solution

by:
wdosanjos earned 500 total points
ID: 35111136
Session state is kept on the server memory by default.  Assuming you are using SSL, why do you think that's unsafe?   You can always encrypt the information in memory, if memory access is a concern.

More on Securing Session State:
http://msdn.microsoft.com/en-us/library/ms178201.aspx
0
 

Author Comment

by:akohan
ID: 35111225

Yes, I do have SSL.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35121528
Do keep in mind, though, that whatever you decide to store in session, every user will have their own session. If you plan to store large objects, saving them to a DB may be a more logical choice.
0
 

Author Closing Comment

by:akohan
ID: 35151040
Thanks
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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

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

26 Experts available now in Live!

Get 1:1 Help Now