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 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 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?
Also read NotACodeMill.