• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to check value initialisation between two servlets

 
rohit raja
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i want to know that if i have one servlet and i am taking input and storing it as operand1(say). and another servlet in which i am doing the same process for operand2.
i want that both servlet should check of others value initialized or not and if so do the multiplication of the same.
please basically tell me how servlet1 will check for servlet2.as for servlet2 we can check through requestdispatcher but how servlet1 will check for servlet2
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a poor design to me. What's the actual use case? There's likely a better way to model this.
 
rohit raja
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Sounds like a poor design to me. What's the actual use case? There's likely a better way to model this.


The actual use case is like two servlet should check each one of them for whether the value taken input in that servlet is initialized or not?

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, that's how you are trying to accomplish it. The question is higher-level: why? What are these values? Why do they need to be shared?
 
rohit raja
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:No, that's how you are trying to accomplish it. The question is higher-level: why? What are these values? Why do they need to be shared?


Actually my teacher have given me this as my assignment which i need to submit by 28 of this month. i am sending you the actual question which he have given to me please help me.

here is the question


Display the sharing of context among different servlets of same web application. First servlet should accept one input and store it as operand1 in session attribute. The second servlet should accept another input and store as operand2. Each of these servlet should check if other attribute is set, and if so, compute the multiplication of two numbers and display the result.
 
Tim Moores
Bartender
Posts: 2955
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question already says how to do it: with session attributes. Read up on those in your textbook -or whatever learning materials you have-, and the way to use them for this should become clear.
 
rohit raja
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:The question already says how to do it: with session attributes. Read up on those in your textbook -or whatever learning materials you have-, and the way to use them for this should become clear.

Actually i already gone through the text book and i framed it also but my actual problem is that i am taking input in first servlet and through request dispatcher i am passing it to second servlet and there its checking for value initialized or not then i will take input in second servlet at that time how the first servlet will check whether the value in second is initialized or not. should i again send use request dispatcher?
 
Tim Moores
Bartender
Posts: 2955
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I see nothing in the problem description that would require a request dispatcher. It states that each servlet should check whether the other has been called already. It says nothing about one calling the other.
 
rohit raja
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:Actually, I see nothing in the problem description that would require a request dispatcher. It states that each servlet should check whether the other has been called already. It says nothing about one calling the other.


Can you please send me the code? please
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please let us know when a question is a school assignment. That way no one wastes time trying to find out why it doesn't make much real-world sense.

Also read NotACodeMill.
 
rohit raja
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Please let us know when a question is a school assignment. That way no one wastes time trying to find out why it doesn't make much real-world sense.

Also read NotACodeMill.


Ok i will do it.thank you for suggesting me
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic