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
Joined: Jan 30, 2000
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
Joined: May 05, 2000
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.
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.