• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in servlet

 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Following is my code.


Here,In the while loop,if the variable extnum contains 2 variables from the database,when i print the extnum in the onManagerEvent,it just prints the last variable of the two variables instead of printing 2 variables.How should i solve this problem.Please assist me to do this.

Thanks
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This should be managed in two separate classes, the responsibilities are separate and you'll just confuse yourself (as in this case) if you try to write it in one class.
 
Jhakda Velu
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Your code is messy. As David said, split your code a bit. Then you should(and we will ) be able to read and understand your code properly. About your question of only one value getting printed, i believe that you mean to ask that you get 2 records, but only one is printed, if this is your question, then check how you are assigning the value from result set, that should lead you to the answer.

Hope it helps

Jhakda
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou for your replies.
i believe that you mean to ask that you get 2 records, but only one is printed, if this is your question


yes.This is my question.

check how you are assigning the value from result set


I dont get you.I am assigning the records from the resultset to a string variable extnum.

I have splitted my codes into two classes like :


The above code is to dial the particular numbers whose flag are 0 from the database .

In the following code , I am just getting the extnum and trying to print.But null is printed.


Please locate me where am i wrong?

Thanks
 
Jhakda Velu
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I think you are not exactly getting the purpose of a Servlet.
In you onManager method, you are just instantiating the Servlet, you don't instantiate a servlet yourself, the container does it.

Now, the question, do you need a servlet or just a POJO?
Please revert with what you exaclty need to do. That way people on the forum will be able to help you better.

In your old code, you were assigning the value to the same string object 2 times, that why only the last value was getting printed. Now you are just instantiating the servlet, so the value is bound to be null

Jhakda

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic