The stack trace from the null pointer exception would be helpful in diagnosing what is
going on. However, if the aForm variable were null, you would definitely get such an
exception before the servlet.log()
method was called -- it would be triggered in your if statement. Have you checked
that?
Craig McClanahan
Anand Raman wrote:
> hi guys
> I am into making a simple application using struts..
>
> A portion of my Action subclass reads
>
> if ("edit".equals(aForm.getAction())) {
> servlet.log("display the artist details of id "+aForm.getArtistId()+" for
>editing with action "+aForm.getAction(),2);
> String sql = "select name, born, education, exhibitions, collections,
>honours, body, links, picture_path, painting_path1, painting_path2, quote from
>artists where artist_id = "+aForm.getArtistId();
> servlet.log(sql,1);
> ResultSet rset = stmt.executeQuery(sql);
> rset.next();
>
> // reset the properties of the action form AFORM and send it to
> // success action forward
> aForm.setArtistId(aForm.getArtistId());
> aForm.setName(rset.getString(1));
> aForm.setBorn(rset.getInt(2));
> aForm.setEducation(rset.getString(3));
> aForm.setExhibitions(rset.getString(4));
> aForm.setCollections(rset.getString(5));
> aForm.setHonours(rset.getString(6));
> aForm.setBody(rset.getString(7));
> aForm.setLinks(rset.getString(8));
> aForm.setPicturePath(rset.getString(9));
> aForm.setPaintingPath1(rset.getString(10));
> aForm.setPaintingPath2(rset.getString(11));
> aForm.setQuote(rset.getString(12));
> aForm.setAction("update");
>
> return mapping.findForward("success");
> }
>
> I am able to get appropriate log messages in servlet.log and also
> execute the sql statement.
>
> However when i try to reassign these values again to the aForm ActionForm subclass i
>get NullPointerException..
>
> I have been unable to comprehend this.. Can some one please suggest
> something..
>
> Thanx
> Anand