It's not a secret anymore!*
The moose likes Struts and the fly likes Problem reg. Delete Operation in my struts application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem reg. Delete Operation in my struts application" Watch "Problem reg. Delete Operation in my struts application" New topic
Author

Problem reg. Delete Operation in my struts application

Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Hi All,
I'm creating a strut application. In this User will click Sign In Link and will enter username/password and after that will be anle to see all the records from database along with Delete link at the end of each records.


But when I click record that record is not deleted. I found that the function in which delete query is mentioned is not being called at all But i am not able to find what is the problem / going wrong. I am not getting any error / Exception. But page goes blank when i click Delete link at end of a record.

Below is the codes.


struts-config.xml
============



userlist.jsp (This is the JSP for displaying the records).
===================================



removeUser Function from LogonData Class
=============================



DeleteUserAction.java
===============



Please help me resolving problem related to delete function.

Thanks in Advance.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I have several concerns about this code, including SQL injection and web crawlers.

That aside, it appears as though the HTML you posted was partially messed up.

If nothing else, you should set logging to DEBUG level and check the logs for any exceptions--I'd imagine there's one there.

Also, try to take care to keep your code clean--there's no reason to try to close a result set that will never be not null. Commented-out code just obfuscates the real code and makes it more difficult for us (and you) to see what's going on. There's no need to ever call new String("foo")--just use an immediate string. You don't need to check to see if errors is empty immediately after adding an error.

Clean code counts--and it makes tracking down issues much, much easier.
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Hi David,

Thanks for reply and valuable suggestions. Actually i'm new to struts and following professional Jakarta Struts Books.

Anyway, Here is the userlist.jsp



Thanks in Advance.
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
It seems thereis a problem in the code that prints Delete link in the JSP. Hence i'm putting that snippet below.


Below is the small snippet from userlist.jsp

<logic:iterate id="user" name="users">
<tr >
<td>
<bean:write name="user" property="username"/>
</td>
<td>
<bean:write name="user" property="password"/>
</td>
<td>
">Delete
</td>
</tr>
</logic:iterate>

Thanks.


David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You need to both disable HTML and use code tags:There's a "Preview" button to allow you to see if your posts are rendering correctly.
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Thanks David for this valuable suggestion
Here is the snippet.
What is going wrong in the code?. How to resolve problem?



Thanks in Advance.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What were the results of the increased debug logging?
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Hi David,

Could you let me know any reference regarding how to set / increase DEBUG level for this application.

Thanks in Advance.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Depends on what logging package you're using, but it starts with setting devMode to true for some basic info.

I use Log4J, so I use either a Log4J properties or XML config file to set up Struts 2 and/or XWork and/or OGNL to log at DEBUG level, depending on the nature of what I'm trying to track down.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Oops, you're using Struts 1. The Log4J stuff applies anyway, as far as I can recall.
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Hi David ,

Thanks for reply. Currently i'm not using log4j package to my struts application. So is it fine if i define DEBUG level in web.xml as an init parameter?


Thanks.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I have no idea; if that will configure commons-logging, sure.
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Hi,

Sorry for late reply.
I tried defining DEBUG level in web.xml but seems that its giving the same log.

Is there another way that can be configured?Even if i use log4j package where do i need to print the logging statements that will help to resolve this issue.

Can some one please help me on above.

Thanks in Advance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem reg. Delete Operation in my struts application