This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
Today , i have a problem which i want to discuss with you'll. Off lately , My company has started given me some code files and that code files are actually written by someone who has already left the company and he did not document eveything. So all the variables or whatever beans , jsp and servlets , its sort of going bouncer over my head.. Its not that i do not know Web component architecture. I have alwayz worked with JSP and Servlets , Beans etc . However , seeing someone's coded files and then to understand them is very tough. Can someone of you , please guide me on how do i go about learning this code files.
Now , the problem. What actually has happened is , there is a combobox in which the user has an option to select the delivery options , The user selects the "Shipping Details" combobox and then submits. Though the user fills in all the details , When it comes to the Database , It is recorded as NULL , NULL , NULL , NULL. There are 8-9 fields related to the shipping details , in all of them this comes as NULL. And the main part which is being killing me is it sometimes does work like butter , nice ! But sometimes like NULL and Null. Does anyone have an idea what can be the problem behind this ?
I again reiterate , it works most of the times , but sometimes just comes as NULL. Also it does not throw any exceptions. How can i check this one ?
WOuld be great if a lot of people suggest on this.
Thanks in Advance.
[Bear edit: explitives removed -- please control your language] [ June 24, 2006: Message edited by: Bear Bibeault ]
Meri Zindagi Hain Tab Tak.. Jab Tak Tera Sahara.... Har Taraf Tu Hi Tu Hain SAI Tera Hi Hain Nazara.....
Also one suggesstion is that don't ask a question that is so long.
Questions should be as long as they need to be. Nothing is more annoying than when someone posts a question that doesn't have enough information to analyze the problem.
Logging (even if only with System.out.println) is your best friend when working through other people's code.
Add lines throughout the code to tell you what the value of all of your variables are at different locations in your code. Then watch your logs as you hit the app. If you're on a Unix box, the tail program will allow you to watch the logs as they are being written, in real time. I believe there is a windows version of tail.
Real logging packages like Log4j allow you to keep the debugging lines in your code but turn the logging levels up or down at run time.
Thanks for replying and letting me know of our realy best friend , System.out.println :-) But the problem is still in question , Why does the same code work perfectly most of the time and also the Database gets filled in correctly while sometimes it records NULL.
This is the start of my Java Career and if this is not resolved , may be i would be revoked the rights to perform Java programming ! :-( Well thats too far away coz i am a member of this great site and reader of great books with great Authors like K & B and Hanumant Deshmukh.
Then too , any help would be highly appreciated. Thanks again.
The reason I gave you that advice is that's what I would do to figure out what's going on. There is no way for someone on this list to determine the nature of you problem. Something is different between the hits that write data to the database and the ones that write nulls. You'll have to figure out what that difference is.
A good part of your career is going to be spent figuring out forgein code; written by someone else or by you a long time ago (often the two aren't much different in practice).
However , seeing someone's coded files and then to understand them is very tough. Can someone of you , please guide me on how do i go about learning this code files.
First analyze the product from an user's perspective. ie., forget about the code. take a piece of paper and write down what you do as an user (Enter Username and password and press login, The Welcome Page is displayed with menus, Click on the maintenance menu....)
Now start by looking at the code for login.jsp and try to understand how the developer had coded it. After that makes sense, move on to the menu page etc..
This approach has always worked for me
MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
Without looking at the code it is impossible to say why things come out null. Welcome to the frustrating world of debugging code.
Are you reliably able to duplicate the error? Or does it just happen every once in a while? Is there code that goes through and sets those values to null? When/why would it get called? Maybe some error handling failed, and it went on to save anyway? Maybe it could be a synchronization/threading problem. Is the page using <%! %> declarations, or servlet attributes which might create a synchronization problem?
Getting an idea of the data flows through the application is crucial to solving it.