This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
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.
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • 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
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
    Bookmark Topic Watch Topic
  • New Topic