今天买了: < <Ajax基础教程> > 一书,是 "人民邮电出版社出版 "的.金灵翻译的.
其中的用来接收ajax传递过来用的是javaservlet但是我用javac编译javaservlet源程序的时候,提示找不到类,我在java的API上也检查了,也查不到它所要求导入的类,请问这是为什么啊?源文件如下:不会是书上印刷错误了吧?(书上的每个sevelet程序都导入了同样的类,也不可能搞错吧,
毕竟这么大的一个出版社吗?:::::::::::::::)
package ajaxbook.chap3;
import java.io.*;
import javax.servlet.*;//提示找不到这个类,到底是为什么啊?
import javax.servlet.http.*;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class PostingXMLExample extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String xml = readXMLFromRequestBody(request);
Document xmlDoc = null;
try {
xmlDoc =
DocumentBuilderFactory.newInstance().newDocumentBuilder()
.parse(new ByteArrayInputStream(xml.getBytes()));
}
catch(ParserConfigurationException e) {
System.out.println( "ParserConfigurationException: " + e);
}
catch(SAXException e) {
System.out.println( "SAXException: " + e);
}
/* Note how the Java implementation of the W3C DOM has the same methods
* as the JavaScript implementation, such as getElementsByTagName and
* getNodeValue.
*/
NodeList selectedPetTypes = xmlDoc.getElementsByTagName( "type ");
String type = null;
String responseText = "Selected Pets: ";
for(int i = 0; i < selectedPetTypes.getLength(); i++) {