Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Edit or View Resultset from Database - Design Question

Status
Not open for further replies.

foramit

MIS
Nov 13, 2002
7
US
I have a JSP page which display a resultset from database, that look something like this

Name1 Age1 Address1 City1 State1


I want to display this result set and also display a edit and View button such as

Edit View Name1 Age1 Addres1 city1 state1
Edit View Name2 Age2 Address2 City2 State2

And I also want to add functionaly such that on click Edit, that particular record is edited ( in different JSP)
or on CLick View that particular record is seen in View Mode.

what are the ways to achieve this ?

Any hints or pointers to design this will be appreciated.

Thanks a lot.
 
The functionality you require is probably best implemented as a combination of a servlet (for the business logic) and one or more JSPs (for the presentation).

You will need to write code that will format the data returned in a ResultSet in a table, adding in the 'edit' and 'view' links. The URLs in these links will need to uniquely identify the record that you need to view or edit (so the code for these tasks knows which record to display or edit).

You will then require two pieces of business logic and two JSPs. The first pair will simply get and display a record given some unique identifier (and so accomplishes the 'view' task). The second pair will be similar to the view task, but will present the data in an editable way and then update the database when the data is changed (and so accomplishes the 'edit' task). You may well find that the code and JSPs for these two tasks is very similar, so you might be able to reduce this problem down to writing the code for just the 'edit' task (since editing something requires you to be able to view what you are editing).

On completion of editing, you will need to update the database with the new details. You can use Java's executeAndUpdate() method on a PreparedStatement object for this.

If you are still confused about how to proceed, I suggest that you read a book on Java web application development (it will need to cover Servlets, JSP and JDBC) as the scope of your question is very broad, suggesting that you might need to get some of the basics down first.

Good luck.
 
essentially edit and view tasks are similar in regard to the retreival of the data. the same query can be used to get the info for both edit and view but on the edit screen you would use drop down boxes, text boxes, text area boxes, check buttons etc to allow changes to be made. on the view page you would just display the info in tables etc, you wouldnt use any textboxes, combo boxes etc. this means that the user has in no way any ability to alter the info.

you can preform all of your tasks using JSP, you dont nessarly have to use servlets at all as the JSP is compiled into servlets. but the servlets do give you a bit more control over certain aspects.

i'd have a look at the JSP/servlets forum
these kinds of questions have been asked a fair amount of times so you should get bits of code that you can use there along with tutorials about the basics and the not so basics.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top