You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by as as <sa...@yahoo.com> on 2004/03/01 17:29:12 UTC

java.lang.NullPointerException struts form is null

Hi,
 
Struts form is giving null in my  action class .execute().Below are my files.Hep appreciated.Thanks
 

import java.io.IOException;

import java.util.List;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;

import org.apache.struts.action.ActionForm;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;



/**

* * @struts.action

* path="/addTeacher"

* name="teacherAddForm"

* scope="request"

* validate="false"

* * @struts.action-forward

* name="success"

* path="/teachers.jsp"

* * @struts.action-forward

* name="failure"

* path="/error.jsp"

*/

public final class TeacherAddAction extends Action {

/**

* @param actionmapping The ActionMapping

* @param actionform The ActionForm object

* @param httpservletrequest The httpservletrequest of the incoming request

* @param httpservletresponse The httpservletresponse corresponding to the request

* @param ActionForward The return path 

*/

public ActionForward execute(

ActionMapping mapping,

ActionForm actionform,

HttpServletRequest request,

HttpServletResponse response)

throws IOException, ServletException {

System.out.println("In TeacherAddAction:");

TeacherAddForm teacherAddForm = (TeacherAddForm) actionform;

if (teacherAddForm == null) teacherAddForm = new TeacherAddForm();

else 

System.out.println("teacherAddForm is not null");

try {

Teacher teacher= null;

teacher.setLast(teacherAddForm.getLast());

**********************

Thanks!



---------------------------------
Do you Yahoo!?
Get better spam protection with Yahoo! Mail

RE: java.lang.NullPointerException struts form is null

Posted by Andrew Hill <an...@gridnode.com>.
Well... doublecheck your mapping in struts config. If you misspelled the
class name or got the wrong form name struts can be rather silent about it
and just give you a null form!

-----Original Message-----
From: as as [mailto:sam_struts@yahoo.com]
Sent: Tuesday, 2 March 2004 00:29
To: struts-user@jakarta.apache.org
Subject: java.lang.NullPointerException struts form is null


Hi,

Struts form is giving null in my  action class .execute().Below are my
files.Hep appreciated.Thanks


import java.io.IOException;

import java.util.List;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;

import org.apache.struts.action.ActionForm;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;



/**

* * @struts.action

* path="/addTeacher"

* name="teacherAddForm"

* scope="request"

* validate="false"

* * @struts.action-forward

* name="success"

* path="/teachers.jsp"

* * @struts.action-forward

* name="failure"

* path="/error.jsp"

*/

public final class TeacherAddAction extends Action {

/**

* @param actionmapping The ActionMapping

* @param actionform The ActionForm object

* @param httpservletrequest The httpservletrequest of the incoming request

* @param httpservletresponse The httpservletresponse corresponding to the
request

* @param ActionForward The return path

*/

public ActionForward execute(

ActionMapping mapping,

ActionForm actionform,

HttpServletRequest request,

HttpServletResponse response)

throws IOException, ServletException {

System.out.println("In TeacherAddAction:");

TeacherAddForm teacherAddForm = (TeacherAddForm) actionform;

if (teacherAddForm == null) teacherAddForm = new TeacherAddForm();

else

System.out.println("teacherAddForm is not null");

try {

Teacher teacher= null;

teacher.setLast(teacherAddForm.getLast());

**********************

Thanks!



---------------------------------
Do you Yahoo!?
Get better spam protection with Yahoo! Mail


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org