Struts: how to debug in Action class

I

itpcl

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 {
 
O

Oscar kind

itpcl said:
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
 
B

Bryce

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)
 
I

itpcl

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
 
S

Sudsy

itpcl said:
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...
 
I

itpcl

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
 
I

itpcl

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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,088
Latest member
JeremyMedl

Latest Threads

Top