• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sending data from one servlet to another..

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As to Jairat's question, simply create a form pointing to the servlet you wish to execute.
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic