• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help reqd. in displaying results

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi friends,

I am doing a project using java servlets,java beans and jsp pages.
I have a customer master form (HTML Or JSP) with input text fields and few buttons for insert,delete,first,next,previous,last.


I have a servlet which will take 'post' request from jsp page when one of these buttons clicked and calls the relavant functions which were implemented in java bean.

My Problem is, I want to display the relevant records in the data input form whenever the user clicks next,previous,delete buttons... etc.

For example, When the user clicks next button , the values in the data input fields should show the next customer record. I am able to pick the correct record from the bean to servlet but how can i replace the existing customer record values with the next customer record values in my data input form. I would like to know how you would implement this if they come across such a requirement.

Regards,
Lakshmi
 
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I good understand your question, I think you should JavaScript to clear the form and fill it with new values.
 
Ranch Hand
Posts: 126
Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When next button is clicked make a call to another servlet/JSP that will query the record and generate the HTML code that will be thrown to the client.

Nitin Dubey
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi lakshmi

I am assuming that you are inserting the bean in the session and reading the bean from session on the jsp.

As you said you are getting the right bean into the servlet, after once you have the bean in the servlet replace this new bean in the session and then forward your request to your jsp then your Jsp will be automatically reloeaded with the data from new bean. (use struts if possible , will make your life easy)
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May be the bean populated with the new set of data retrieved from the database, is not set in session.

Use a JSP to display the records, in your JSP use the usebean tag to show the data.

or create the bean with data retrieved from database, and put it in request object.
request.setAttribute("mybean");

and get this bean in the jsp
request.getAttribute("mybean");

and display the values from the bean as follows

<%

MyBean myBeanObj = (MyBean) request.getAttribute("mybean");
String username = myBeanObj.getUserName();

%>

<input type=text name=mytextbox value= "<%=username%>">
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic