• Post Reply Bookmark Topic Watch Topic
  • New Topic

How a servlet can know the cell selected in a table on a html form contained in a JSP page?  RSS feed

 
John-Philippe Verger
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a JSP page in which there is an html form , and in this form there is a html table of 10 rows and 3 columns. When this JSP page is displayed in the browser of the user, I would like that when the user selects a cell in the table, a POST is sent to a servlet so that a processing is done in a database , based on the position of the cell. My problem is that I don't know how to write the code for the html table so that when the user selects a cell in the table, the servlet to which the form is posted is able to know the position of the cell( the position of the cell means, for me, the row and the column to which the cell belongs).
Please, how to solve my problem?

Thanks you in advance for your help.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66153
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Include the position information in hidden inputs.
 
John-Philippe Verger
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you Bear Bibeault for the reply. But, please ,can I have more concrete information on how to put hidden inputs in the code for the html table?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66153
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not without more information on your part. You just need to make sure that whatever is triggering the submission of the form fills in the hidden inputs with the appropriate values. Probably some JavaScript needs to be involved.
 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John, can you describe more about your problem

You said that, user selects a cell, how can a client select a html table cell, are you using any checkbox in it?

One more thing is, you mentioned that when a user select a cell a POST request is sent to a servlet, are you using AJAX? or are you using a form button to call the servlet?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66153
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anusha chaitanya wrote:One more thing is, you mentioned that when a user select a cell a POST request is sent to a servlet, are you using AJAX? or are you using a form button to call the servlet?

What does any of that matter? Regardless of how the request is generated "cell info" is not the type of information that is available unless something is done to provide it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!