File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Passing data to two servlets? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Passing data to two servlets?" Watch "Passing data to two servlets?" New topic
Author

Passing data to two servlets?

mallikarjun dontamsetti
Ranch Hand

Joined: Mar 18, 2011
Posts: 244

Is it possible to pass same form data to different servlets at a time
Thanks
Georges Salameh
Greenhorn

Joined: Jun 15, 2011
Posts: 4
I did not get what you are going but if you are for example filling a form with fields on multiple servlets you can simply use a java Bean to save the data and retrieve the bean wherever you want in your application.
Ashutosh Limaye
Ranch Hand

Joined: Oct 24, 2005
Posts: 58
Can't do it through form action; but could achieve it through javascript. see XMLHttpRequest
mallikarjun dontamsetti
Ranch Hand

Joined: Mar 18, 2011
Posts: 244

I want to send the form data directly, not by using another controller(servlet) or setting a bean.because i have to edit my previous servlet(which we are using in the application).So please tell me how to invoke two servlets from one html/jsp.
Ashutosh Limaye
Ranch Hand

Joined: Oct 24, 2005
Posts: 58
Georges Salameh wrote:I did not get what you are going but if you are for example filling a form with fields on multiple servlets you can simply use a java Bean to save the data and retrieve the bean wherever you want in your application.

What if the form is on a .html file, how do you access your bean there to fill it with form data?
mallikarjun dontamsetti
Ranch Hand

Joined: Mar 18, 2011
Posts: 244

What if the form is on a .html file

I am just getting required fields in the servlet and using there only
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

mallikarjun dontamsetti wrote:because i have to edit my previous servlet(which we are using in the application).

What do you mean by editing the previous servlet?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
mallikarjun dontamsetti
Ranch Hand

Joined: Mar 18, 2011
Posts: 244

Vijitha Kumara wrote:
mallikarjun dontamsetti wrote:because i have to edit my previous servlet(which we are using in the application).

What do you mean by editing the previous servlet?

In my application we have to add some module. we are using a servlet to act as controller.We have to add some more fields to jsp(Form) and the controller for new module will be another servlet(As my lead said) it is working separate from main servlet. i have to give only few fields(newly added and some old) to new servlet.So i am searching for passing data for multiple servlets at a time.If there is any possibility please suggest me.
Thanks for replies....All
Ashutosh Limaye
Ranch Hand

Joined: Oct 24, 2005
Posts: 58
mallikarjun dontamsetti wrote:
Vijitha Kumara wrote:
mallikarjun dontamsetti wrote:because i have to edit my previous servlet(which we are using in the application).

What do you mean by editing the previous servlet?

In my application we have to add some module. we are using a servlet to act as controller.We have to add some more fields to jsp(Form) and the controller for new module will be another servlet(As my lead said) it is working separate from main servlet. i have to give only few fields(newly added and some old) to new servlet.So i am searching for passing data for multiple servlets at a time.If there is any possibility please suggest me.
Thanks for replies....All


Why aren't you accepting all the data in one servlet and passing the only the relevant data to the next servlet from this servlet?
mallikarjun dontamsetti
Ranch Hand

Joined: Mar 18, 2011
Posts: 244

As i said above i have no option (my lead is the boss) he doesn't want the communication between two servlets or setting/extending bean class
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

So i am searching for passing data for multiple servlets at a time.If there is any possibility please suggest me.

I don't think you can do this by a single form submission. Servlet specification does not provide such a feature as per my understanding. But you can consider AJAX for talking to other servlet(s) while you are on the form which are triggered by form events, is this feasible for you?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

Vijitha Kumara wrote:Servlet specification does not provide such a feature as per my understanding.

It has nothing to do with servlets at all but with HTTP.

And yes, Ajax is the most likely recourse.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
assert assertion
Greenhorn

Joined: Jul 14, 2011
Posts: 8
If you don't want to use AJAX the other option is using multiple Iframes and post the form using java script . While posting set the target of the form = name of the Iframe.
mallikarjun dontamsetti
Ranch Hand

Joined: Mar 18, 2011
Posts: 244

Thanks for replies alllllllll
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing data to two servlets?