Solved

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

Posted on 2003-11-19
5
276 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
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Title # Comments Views Activity
session bean client machine 9 63
Clear browser cache on site login, is it possible? 3 31
How to Post an If Statement in JSP 3 60
running on tomcat not jboss eap 7.0 3 18
IT certifications are a concrete representation of continual learning on the part of the candidate.  Continual learning is necessary for the long term success of an IT professional, but are IT certifications the right path for you?
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 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