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 Sending data from one servlet to another.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Sending data from one servlet to another.." Watch "Sending data from one servlet to another.." New topic
Author

Sending data from one servlet to another..

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi I have ServletA, which has html table output. For each row I have a form element created and at the end of each form I have a submit button. When the user submit, that particular row of data has to be sent to another servlet B. Please Suggest how do I do it?
Thanks
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
I have no answer to your question. Only more questions
WHY oh why are you having servlets generate HTML output? I know this is chapter one of servlets books; how we can do CGI in Java
What Sun suggests for an effective presentation of a Web application, is that you delegate presentation to JSP pages and have Java servlets prep those JSPs with the appropriate beans (objects) that those JSPs will need to render the appropriate UI...
It was called "Model 2" architecture in the "old" servlet days


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Not all of us are as deeply in love with JSP as the Sun marketing team. There are huge holes in JSP. Debugging is a huge pain. And it does not solve the issue of separation of HTML from code. A well designed HTML templating scheme is 1000X better than the JSP hack as far as I am concerned.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
As to Jairat's question, simply create a form pointing to the servlet you wish to execute.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
And Jairat, I must ask you again to change your registration to a first and last name format. If you don't, the owners of this web site will revoke your registration.
Please look at this: http://www.javaranch.com/ubb/Forum10/HTML/000180.html
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
I can see a few ways of doing what you require (separate "submit" buttons for each line of a table).
1. Use a separate form for each line of the table. This works well if you don't also need any operations on all the lines at once. You can send the data to the same servlet, but put the row number in a hidden field:

2. Take advantage of the form behaviour with submit buttons. Only the button clicked is sent to the server with the form, all other buttons are ignored, so you can name the button in a unique way:

I'm sure there are other ways, but these two should do for the moment.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sending data from one servlet to another..