Solved

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

Posted on 2003-11-19
5
280 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Why do some people recommend buying business VoIP from an ISP? What are the benefits to my company? What are the costs?
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

623 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