null pointer exception

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chramprasad
    New Member
    • May 2006
    • 3

    #1

    null pointer exception

    public ActionForward edit(ActionMapp ing mapping, ActionForm form,
    HttpServletRequ est request, HttpServletResp onse response)
    throws Exception {
    MissionForm missionForm = (MissionForm) form;

    String strMissionId = InsEncr.getSing leton().decrypt (missionForm.ge tMissionId().to String());

    Long userEntityTypeI d = getUserEntityTy peId(request);
    String strUserEntityTy peId = String.valueOf( userEntityTypeI d);
    String actionForward = PARAM_EDIT_MISS ION;
    if (!StringUtil.is Empty(strMissio nId)) {
    actionForward = handleEditWhenM issionIsNotNew( strMissionId, mapping, request);
    } else if (Constants.Enti tyType.NATIONAL .equals(strUser EntityTypeId) ||
    Constants.Entit yType.SECTORIAL .equals(strUser EntityTypeId)) {
    actionForward = handleAddMissio nWhenEntityIsNa tionalOrSectori al(request);
    }

    return mapping.findFor ward(actionForw ard);

    }

    In the above when i execute to add a new item its throwing exception null pointer exception
    String strMissionId = InsEncr.getSing leton().decrypt (missionForm.ge tMissionId().to String());

    so anyone can get the solution so that it shouldnot throw exception

    advance thanks
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    I would guess that the most likely problem is that form is not a MissionForm and so when you cast it (which is quite a bad idea) to MissionForm and then try to call the GetMissionId member that member does not exist for form causing an exception.

    Assuming this is C++ you may wish to consider using dynamic_cast to cast your form ensuring that it is actually possible to do it (and catch the exception that happens if it isn't).

    Comment

    • chramprasad
      New Member
      • May 2006
      • 3

      #3
      nullpointer exception

      Originally posted by Banfa
      I would guess that the most likely problem is that form is not a MissionForm and so when you cast it (which is quite a bad idea) to MissionForm and then try to call the GetMissionId member that member does not exist for form causing an exception.

      Assuming this is C++ you may wish to consider using dynamic_cast to cast your form ensuring that it is actually possible to do it (and catch the exception that happens if it isn't).


      its missionform and missionid is also present but like when executing its taking null value to missionid and displaying nullpointerexce ption.only java

      Comment

      • chramprasad
        New Member
        • May 2006
        • 3

        #4
        its missionform and missionid is also present but like when executing its taking null value to missionid and displaying nullpointerexce ption.only java

        Comment

        Working...