Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Struts: how to debug in Action class

Reply
Thread Tools

Struts: how to debug in Action class

 
 
itpcl
Guest
Posts: n/a
 
      06-17-2004
In the following coding, the cryptoPassword1 is always
not equal to cryptoPassword2.

I want to check if anything goes wrong.

What is the usual way to debug a action class?

Thanks


public class RegisterAction extends Action {
public ActionForward perform (ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res)
{

RegisterForm rf = (RegisterForm) form;

String username = rf.getUsername();
String password1 = rf.getPassword1();
String password2 = rf.getPassword2();

GenPassword cryptoPassword1 = new GenPassword(password1, "MD5");
GenPassword cryptoPassword2 = new GenPassword(password2, "MD5");

if (cryptoPassword1.equals(cryptoPassword2)) {
try {
 
Reply With Quote
 
 
 
 
Oscar kind
Guest
Posts: n/a
 
      06-17-2004
itpcl <(E-Mail Removed)> wrote:
> What is the usual way to debug a [struts] action class?


I don't know about others, but I use logging (with Log4J). After
reproducing the error, I can then check the log to see what went wrong.

Another method is to start your application server in debugging mode,
something many (all?) often-used IDE's can do. In that case you can also
set a breakpoint and step through the execution.


kind regards,
Oscar

--
Oscar Kind http://home.hccnet.nl/okind/
Software Developer for contact information, see website

PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
 
Reply With Quote
 
 
 
 
Bryce
Guest
Posts: n/a
 
      06-17-2004
On 16 Jun 2004 20:38:04 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) (itpcl) wrote:

>In the following coding, the cryptoPassword1 is always
>not equal to cryptoPassword2.
>
>I want to check if anything goes wrong.
>
>What is the usual way to debug a action class?


Set breakpoints and step through it?

Use System.out.println? (or Log4J)

>public class RegisterAction extends Action {
> public ActionForward perform (ActionMapping mapping,
> ActionForm form,
> HttpServletRequest req,
> HttpServletResponse res)
>{
>
> RegisterForm rf = (RegisterForm) form;
>
> String username = rf.getUsername();
> String password1 = rf.getPassword1();
> String password2 = rf.getPassword2();
>
> GenPassword cryptoPassword1 = new GenPassword(password1, "MD5");
> GenPassword cryptoPassword2 = new GenPassword(password2, "MD5");
>
> if (cryptoPassword1.equals(cryptoPassword2)) {
> try {



--
now with more cowbell
 
Reply With Quote
 
itpcl
Guest
Posts: n/a
 
      06-18-2004
Any example of Log4J?
I do not know how to use Log4J
I am using Eclipse and Tomcat.
How can I start them in debug mode?

Thnx

> I don't know about others, but I use logging (with Log4J). After
> reproducing the error, I can then check the log to see what went wrong.
>
> Another method is to start your application server in debugging mode,
> something many (all?) often-used IDE's can do. In that case you can also
> set a breakpoint and step through the execution.
>
>
> kind regards,
> Oscar

 
Reply With Quote
 
itpcl
Guest
Posts: n/a
 
      06-18-2004
I have tried System.out.println.
Nothing prints out.

>
> Use System.out.println? (or Log4J)
>

 
Reply With Quote
 
Sudsy
Guest
Posts: n/a
 
      06-18-2004
itpcl wrote:
> I have tried System.out.println.
> Nothing prints out.


System.err.println and tail -f $TOMCAT_HOME/logs/stdout.log (at
least that's how it works in V3.3.1). I'll have to check my
4.1.29 config...

 
Reply With Quote
 
itpcl
Guest
Posts: n/a
 
      06-18-2004
>
> System.err.println and tail -f $TOMCAT_HOME/logs/stdout.log (at


The following is the log files I find.
No debug print message is found.

[pcleung@homeHost logs]$ pwd
/opt/jakarta-tomcat-5.0.25/logs
[pcleung@homeHost logs]$ ls -l
total 52
-rw-r--r-- 1 root root 34181 Jun 18 21:40 catalina.out
-rw-r--r-- 1 root root 2675 Jun 15 22:50 localhost_log.2004-06-15.txt
-rw-r--r-- 1 root root 8126 Jun 16 23:27 localhost_log.2004-06-16.txt
-rw-r--r-- 1 root root 875 Jun 18 21:40 localhost_log.2004-06-18.txt
 
Reply With Quote
 
itpcl
Guest
Posts: n/a
 
      06-18-2004
>
> I don't know about others, but I use logging (with Log4J). After
> reproducing the error, I can then check the log to see what went wrong.


I have tried to use Log4J as the following coding.
But I encounter error like this.

java.lang.NoClassDefFoundError: org/apache/log4j/Category
java.lang.Class.getDeclaredConstructors0(Native Method)

What need to be added?

public class RegisterAction extends Action {
private static Logger logger = Logger.getLogger(RegisterAction.class);
public ActionForward perform (ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res) {
RegisterForm rf = (RegisterForm) form;
String username = rf.getUsername();
String password1 = rf.getPassword1();
String password2 = rf.getPassword2();
logger.debug("password1:" + password1);
logger.debug("password2:" + password2);
GenPassword cryptoPassword1 = new GenPassword(password1, "MD5");
GenPassword cryptoPassword2 = new GenPassword(password2, "MD5");
logger.debug("c password1:" + cryptoPassword1);
logger.debug("c password2:" + cryptoPassword2);
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can we call an Action from another Action in struts??? vyshu Java 1 04-27-2007 09:19 AM
Struts mapping action to action??? runescience Java 3 02-07-2006 04:07 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
Struts Forward to an Action from an to Action and URLs rjweytens Java 6 06-25-2004 01:49 PM
Struts Static Action Form vs Dyanamic Action Form Joe Bloggs Java 1 08-03-2003 02:30 AM



Advertisments