Struts: how to debug in Action class

Discussion in 'Java' started by itpcl, Jun 17, 2004.

  1. itpcl

    itpcl Guest

    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 {
     
    itpcl, Jun 17, 2004
    #1
    1. Advertising

  2. itpcl

    Oscar kind Guest

    itpcl <> 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
     
    Oscar kind, Jun 17, 2004
    #2
    1. Advertising

  3. itpcl

    Bryce Guest

    On 16 Jun 2004 20:38:04 -0700, (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
     
    Bryce, Jun 17, 2004
    #3
  4. itpcl

    itpcl Guest

    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
     
    itpcl, Jun 18, 2004
    #4
  5. itpcl

    itpcl Guest

    I have tried System.out.println.
    Nothing prints out.

    >
    > Use System.out.println? (or Log4J)
    >
     
    itpcl, Jun 18, 2004
    #5
  6. itpcl

    Sudsy Guest

    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...
     
    Sudsy, Jun 18, 2004
    #6
  7. itpcl

    itpcl Guest

    >
    > 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
     
    itpcl, Jun 18, 2004
    #7
  8. itpcl

    itpcl Guest

    >
    > 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);
     
    itpcl, Jun 18, 2004
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe Bloggs
    Replies:
    1
    Views:
    923
    Sudsy
    Aug 3, 2003
  2. rjweytens
    Replies:
    6
    Views:
    16,249
    rjweytens
    Jun 25, 2004
  3. runescience

    Struts mapping action to action???

    runescience, Feb 6, 2006, in forum: Java
    Replies:
    3
    Views:
    1,913
    runescience
    Feb 7, 2006
  4. vyshu
    Replies:
    1
    Views:
    2,629
    Richard Senior
    Apr 27, 2007
  5. John
    Replies:
    0
    Views:
    975
Loading...

Share This Page