• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

Unhandled Exception - getXmlTemplate().replaceAll()


The indidated line below gives me this error:
            org.apache.struts.action.RequestProcessor processException
                WARNING: Unhandled Exception thrown: class java.lang.NullPointerException

and this is getXmlTemplate() is just getter function.
public ActionForward create(ActionMapping mapping,
                                                       ActionForm form,
                                                       HttpServletRequest request,
                                                       HttpServletResponse response)
                  throws Exception {
                        String typeId = request.getParameter("testSelection");
                        AssessTestTypeDAO typeDAO = new AssessTestTypeDAO();
                        AssessTestType type = typeDAO.select(typeId);
                        typeDAO = null;
                        if (type != null)
                            String xml = type.getXmlTemplate().replaceAll("\t|\n", ""); ------> error
                            String xsl = type.getHtmlXSLFile();

any idea?

1 Solution
You are checking that type != null but not "type.getXmlTemplate() != null".

When you call replaceAll on the String returned by .getXmlTemplate() it is failing as it is returning a null not a String.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now