• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Problem reg. Delete Operation in my struts application

 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What were the results of the increased debug logging?
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops, you're using Struts 1. The Log4J stuff applies anyway, as far as I can recall.
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no idea; if that will configure commons-logging, sure.
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 am a man of mystery. Mostly because of this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic