Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4025986
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:54:52+00:00 2026-05-20T10:54:52+00:00

One more question related to my Struts form, and I will move on to

  • 0

One more question related to my Struts form, and I will move on to other things. I finally figured out how to implement a form with two buttons. I am sending the name attribute of the s:submit button clicked on by the user to the execute() method of my action class. I have a String variable associated with each button, and the variable of the selected button is (quite obviously) the one that gets set, and I want a different method performed for each button. When I click on the first button, no problem. The problem occurs when I click on the second button. I get a NullPointerException associated with the first String. I could swear the String in question started out as null, and that’s what I’m checking for, so I can’t see why there would be a problem. I am including the getters and setters as well as the execute() method. Any ideas out there?

public String getApprove() {
    return approve;
}

public void setApprove(String approve) {
    this.approve = approve;
}

public String getDeny() {
    return deny;
}

public void setDeny(String deny) {
    this.deny = deny;
}

public String execute() {
    BulletinDAO bulletinDAOInstance = new BulletinDAO();

    <!-- Error occurs here when approve is null -->
    if (! approve.equals(null)) {
        if (bulletinDAOInstance.approveBulletin(id) == true) {
            return "success";
        }           
    }

    if (! deny.equals(null)) {
        if (bulletinDAOInstance.denyBulletin(id) == true) {
            return "success";
        }                       
    }

    return "failure";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:54:53+00:00Added an answer on May 20, 2026 at 10:54 am

    approve.equals(null) will never be true, if approve is null that will cause null pointer exception because you’re trying to call a function on a null object.

    use if(approve == null) which compares the location in memory instead of the contents of the object

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys, one more quick question for any experts out there. I have a
This is kinda....a two part question. The first one is much more important than
Actually my question is more related to dll. I have one application GUI (name:
I have one more question related to this thread. How to decode some number
Actually this is more than one question, but seems kind related. I appreciate any
Edited 3.9.2011 to add one more related question Hello, I'm very new to WCF
i'm back with one more question related to BASS . I already had posted
One more question about most elegant and simple implementation of element combinations in F#.
UPDATED: Added one more question (Question #4). Hi all, I'm building myself a custom
Hey guys I have one more question lol. I am using a script that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.