|
I have a class that operates in the same way a
hashmap does and I want to be able to convert it to an org.w3c.dom.Element (then
to an org.w3c.dom.Document or DocumentImpl).
The code I'm trying to use recurses onto itself to
create a new element each time it comes across a nested HashMap
object.
For example:
<%!
public Element convertHashMap(HashMap hm,
Document doc){
Iterator it =
hm.keySet().iterator();
while(it.hasNext()){
String key = (String)it.next();
//all hashmap keys are strings
Element topElement =
doc.createElement(key); Object
obj = hm.get(key); if(obj instanceof
java.util.HashMap){
HashMap hm2 =
(HashMap) obj;
Element
tempElement = convertHashMap(hm2,doc);
if(tempElement!=null)
topElement.appendChild(tempElement);
}
}
return tempElement;
}
%> When I try and run this method in a JSP I get:
Error: 500 Location: /Centauri/CommonCockpit/src/com/proxima/centauri/servlets/servicemodel/testPage.jspInternal Servlet Error:java.lang.IllegalStateException: Response has already been committed at org.apache.tomcat.core.HttpServletResponseFacade.sendError(HttpServletResponseFacade.java:157) at org.apache.jasper.runtime.JspServlet.unknownException(JspServlet.java:299) at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:377) at com.borland.jbuilder.webserverglue.tomcat.jsp.JspLoaderEcho.service(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559) at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:160) at org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338) at java.lang.Thread.run(Thread.java:484) Does this mean the doc has been closed or something? Is it possible to
actually perform such an operation?
Cheers,
Anthony Ikeda
|
