aspose file tools*
The moose likes Servlets and the fly likes how to check value initialisation between two servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to check value initialisation between two servlets" Watch "how to check value initialisation between two servlets" New topic
Author

how to check value initialisation between two servlets

rohit raja
Greenhorn

Joined: Mar 24, 2012
Posts: 6
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

Joined: Jan 10, 2002
Posts: 61420
    
  67

Sounds like a poor design to me. What's the actual use case? There's likely a better way to model this.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
rohit raja
Greenhorn

Joined: Mar 24, 2012
Posts: 6
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

Joined: Jan 10, 2002
Posts: 61420
    
  67

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

Joined: Mar 24, 2012
Posts: 6
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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Mar 24, 2012
Posts: 6
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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Mar 24, 2012
Posts: 6
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

Joined: Jan 10, 2002
Posts: 61420
    
  67

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

Joined: Mar 24, 2012
Posts: 6
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to check value initialisation between two servlets