• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP page with four buttons

 
Baranidharan Ramakoti
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JSP page with four buttons and text areas to display data from the database.
The four buttons are used to navigate through the database viz., First,Previous,Next,Last records.

The records are displayed in the same page with the fields in their respective text areas

I need to call another Java class where I am connecting with the database with the help of a Hibernate Session.

I tried connecting the Java class with the help of button click event but could not do it. I dont know how to implement and get the data from the database so as to display it in the JSP page when the respective event occurs.

Some one please help me in this issue and give me an idea on this one, so that it would be very helpful for me to complete my project.

Thanks in Advance
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Baranidharan Ramakoti wrote:I I tried connecting the Java class with the help of button click event but could not do it.

Of course not. A click event will invoke JavaScript on the client, not server-side Java. But what you can do in the JavaScript is to cause the form to be submitted (to submit and refresh the entire page) or use Ajax to fetch data from the server without a page refresh.

P.S. If submitting a form, you can get away without any JavaScript by making the buttons of type submit.
 
Baranidharan Ramakoti
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Bear Bibeault for your valuable reply.

But if I have four submit buttons in my form, how will I keep track of which submit button is clicked by the user, in the controller servlet?

Is there any way/function in HttpServletRequest class to get the "value" of the "Submit" button from the JSP page?

If it is possible, then i can directly check, which submit button is clicked, and then call my model class so as to retrieve data from database by passing appropriate parameters

Kindly help me with a sample code....

Thanks a lot.


 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Baranidharan Ramakoti wrote:But if I have four submit buttons in my form, how will I keep track of which submit button is clicked by the user, in the controller servlet?

Give them a name/value pair just like any other input element.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Baranidharan Ramakoti wrote:
Is there any way/function in HttpServletRequest class to get the "value" of the "Submit" button from the JSP page?


Yes. it is possible . how will you get the input parameters from user ?
 
Baranidharan Ramakoti
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Mr.Seetharaman and Mr.Bear Bibeault for helping me out solve this issue.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Baranidharan Ramakoti wrote:Thanks a lot Mr.Seetharaman and Mr.Bear Bibeault for helping me out solve this issue.


You are Welcome
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!