for (int i = 0; i < nL.getLength(); i++) { Node n = nL.item(i); if (((n.getParentNode()).getNodeName()) .equalsIgnoreCase((element.getTagName()))) { return (Element) nL.item(i); } } if (nL.getLength() == 0) { throw new RuntimeException("Element <" + name + "> not found"); } //end of if return (Element) nL.item(0);
}
public Element getBodyElement(String name) { NodeList nL = xmlDocument.getElementsByTagName(name); if (nL.getLength() == 0) { throw new RuntimeException("Element <" + name + "> not found"); } //end of if return (Element) nL.item(0); }
public Vector getChildElements(Element parentElement) { NodeList nL = parentElement.getChildNodes(); if (nL.getLength() == 0) { throw new RuntimeException("No child elements found"); } Vector vElements = new Vector(); for (int i = 0; i < nL.getLength(); i++) { Node node = nL.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { vElements.add((Element) node); } } return vElements; }
public Vector getChildElements(Element parentElement, String name) { NodeList nL = parentElement.getChildNodes(); if (nL.getLength() == 0) { throw new RuntimeException("No child elements found"); } //end of if Vector vElements = new Vector(); for (int i = 0; i < nL.getLength(); i++) { Node node = nL.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { String nodeName = trimNS(node.getNodeName()); if (nodeName.equalsIgnoreCase(name)) { vElements.add((Element) node); } } //end of if } return vElements;
} //end of getElements(Element, String)
public Element getFirstChildElement(Element element) { NodeList nL = element.getChildNodes(); for (int i = 0; i < nL.getLength(); i++) { Node node = nL.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { return (Element) node; } } //end of for
throw new RuntimeException( element.getTagName() + " does not have " + "any child elements."); }
public String trimNS(String nameWithNS) { int index = nameWithNS.indexOf(":"); if (index != -1) { nameWithNS = nameWithNS.substring(index + 1); } return nameWithNS; } //end of trimNS(String)
public String writeXML() { try { TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(); DOMSource source = new DOMSource(xmlDocument);
StreamResult result = new StreamResult(new java.io.FileOutputStream("d:\\puvvada\\jsp\\jaxb\\SecureFileconfig.xml")); transformer.transform(source, result); return result.getOutputStream().toString(); } catch (Exception e) { throw new RuntimeException("Unable to convert the XMLDocument to String"); } }
Iam sending the code.please see and tell me what may be the exception
Khan Malamir
Greenhorn
Joined: Sep 09, 2005
Posts: 16
posted
0
The exception must have appeared somewhere - in logs or in server console. I suspect this code:
This is a guaranteed error, but I wonder why you did not get a compile error when the JSP was compiled. You don't even need that cast since getParameterValues(...) already returns a String[].
subrahm puvvada
Greenhorn
Joined: Aug 23, 2005
Posts: 14
posted
0
sorry i have given there stringarray only not string. i have forgotten to modify and posted
Khan Malamir
Greenhorn
Joined: Sep 09, 2005
Posts: 16
posted
0
Then please do search logs and traces for exception informations, also you can add System.out.println(...) statements in your code to locate the code that generates the exception. I doubt we can help you without additional information.
Khan Malamir
Greenhorn
Joined: Sep 09, 2005
Posts: 16
posted
0
It seems you got answer in your other thread. Posting several threads for the same thing is bad practice because you waste other people's time. Please take the time to read the CarefullyChooseOneForum of 'how to ask'.
Sravan Kumar
Ranch Hand
Joined: Sep 11, 2005
Posts: 121
posted
0
As I have said in another post by you for the same issue, you do not get an Exception. You have printed out the String[].
out.println(rootvalue+checkedValues);
This prints the address of the String[] "checkedValues" and not the elements.
Please do not cross-post the same question in in the same or across multiple forums. It wastes people's time when multiple redundant conversations take place.