Solved

How to Remove a particular record in a JSP Page (without deleting it from the Database) ...

Posted on 2003-11-19
5
279 Views
Last Modified: 2010-04-01
Hello Experts,

 I have a table " company " in my database with fields as shown:

company name               address                  phone number             Remove

  ABCDEFG                 12, XX , YYY.                   11111111                remove
  QWERTZ                  32, FF, GFE.                    44444444                remove

and so on............(upto 2000 companies displaying in 50 Pages...i.e. Records per page - 40)

I am able to connect to my 'Postgresql database' and display all the records in my JSP Page.

Now, When i click the ' remove ' button, the JSP page must be reloaded in such a way that the 'Selected Company' is removed from that Page, but not from the database.

Hope you understand the problem. If not, please tell me...I'll post my Coding part...

Expecting your earlier reply,
Regards ,
Jagdeesh
0
Comment
Question by:jaggybala2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 15

Assisted Solution

by:jimmack
jimmack earned 50 total points
ID: 9777421
One quick solution would be to store the removed elements in an ArrayList.

When the page is first loaded, create a new ArrayList.

When the page is loaded with a company name to be removed, add this to the ArrayList, then when you Iterate through the ResultSet to create the table, for each row, use the contains() method of the ArrayList to see if you have added the company that you are about to display.  If contains() returns true, don't display it.

Store the ArrayList in the session.

Any good?
0
 

Author Comment

by:jaggybala2
ID: 9777577
Thanx for your comment Jimmack...

By the way, at the end of the JSP Page , I have a button named 'EXECUTE ACTIVITIES'...When i click that button, some activities(those activities 'ActivityList.jsp' are included inside the above 'CompanyList.jsp' File) must be inserted into the 'COMPANY TABLE - ACTIVITY FIELD'  ...

When i do like what you have suggested, Is it possible ?

Thanx,
Jagdeesh.
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9777591
Similar thing.  If the data created in the ActivityList.jsp are stored in a session variable, this can be accessed from within the CompanyList.jsp page and the appropriate items included.
0
 
LVL 19

Accepted Solution

by:
Kuldeepchaturvedi earned 100 total points
ID: 9777702
Here is how I would do it...
1. First load the jsp.....
2. create a Hashtable and put it in the session.....
3. Assuming there are only delete/change options that you are allowing users to perform....
4. let them delete/change the rows they want to...
5. at the time this jsp gets submitted back to the server...
6. Pick all the rows and operations and put them in hashtable ..
Hashtable h1= (Hashtable)session.getAttribute("myhash");
h1.put(yourrecordkey, operation);
7. now read the database and put a if condition in it
while(rs.next())
{
if(h1.get(rs.getString("key")!=null)
{
show on grid
}
else
{
do not show...
}
}

8. When user hits the execute activities
9. get the hashtable from session...
10. Start getting the keys and operations from the hashtable and execute them on the database...

end of algorithm.
Hope this helps you
Regards
0
 
LVL 6

Expert Comment

by:jarasa
ID: 9778696
Hi there.
I'm trying to understand why you want to remove a record from the page and not from the table, but I guess the best way you can do is to put a remove_date field in your Company table and use it as a filter so you only show the ones who have no remove_date. If the problem is that diferente users sees diferent companies in their own wallet, then you should make a wallet table where you hold the user->company relationship and then you show only the user companies and you can remove the company from the user without removing the company from the table.
Anyway I guess you should give me more information, but you should analize your situation becose there are many times that is easier to restrict things on the Database instead of doing it by code, and is much cleaner and easier to deal with.
best regards
Javier
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
rebasing and merging used in SCM 1 85
Set up Wildfly 10 8 469
'exit' is not valid keyword in java 14 163
excpetion with multiple catch 11 141
This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
A hard and fast method for reducing Active Directory Administrators members.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question