XML Server Getting Started    
Appendix A: ServletParameters   Helper Class used in this tutorial 
import java.io.*; 
import javax.servlet.*; 
import javax.servlet.http.*; 
import org.xml.sax.InputSource; 
import org.w3c.dom.Document; 
import org.w3c.dom.NamedNodeMap; 
import org.w3c.dom.Node; 
import org.w3c.dom.NodeList; 
public class ServletParameters 
{ 
public ServletParameters(HttpServletRequest req, ServletContext sc) throws Exception { 
_req = req; 
_sc = sc; 
         
String contentType = req.getContentType(); 
String contextXML = req.getParameter("contextXML"); 
InputSource is ; 
if ( contextXML!=null ) 
is = new InputSource( new StringBufferInputStream(contextXML)); 
else 
is = new InputSource(req.getInputStream()); 
org.apache.xerces.parsers.DOMParser parser = new org.apache.xerces.parsers.DOMParser(); 
parser.parse( is ); 
_doc = parser.getDocument(); 
} 
    public HttpServletRequest getServletRequest() { 
   return _req; 
  
} 
    public Document getDocument() { 
   return _doc; 
  
} 
    public ServletContext getServletContext() { 
   return _sc; 
  
} 
public String get(String name) { 
return getParameter(_doc, name); 
} 
private void put(String name, String value) { 
 2000 2002 Computer Technology Inc. All rights reserved. 
Page 59 




J2EE Web Hosting Tundra XML Server Pages J2EE Hosting




 
TotalRoute.net Business web hosting division of Vision Web Hosting Inc. All rights reserved.