Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help reqd. in displaying results

 
Priya Sri
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • 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
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • 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.
 
Nitin Dubey
Ranch Hand
Posts: 126
Oracle
  • Mark post as helpful
  • send pies
  • 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
 
Murthy Cherukumilli
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • 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)
 
Senthil B Kumar
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • 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%>">
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic