• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JSP page with four buttons

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic