日期:2014-05-20  浏览次数:20858 次

jsp中操作xml运行不了??
我有两个文件
XML.jsp文件内容如下:
<%@ page language="java" import="java.util.*" pageEncoding="GBK" contentType="text/html;charset=gb2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <base href="<%=basePath%>">
   
  <title>书目信息</title>
   
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">  
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

  </head>
  
  <body>
  <form action="XMLDao.jsp?action=submit" method="post">
<font size="3">
<br />
书名:<input type="text" name="bookname" size="20" />
<br />
索引号:<input type="text" name="indexnm" size="20" />
<br />
出版社:<input type="text" name="bookconcern" size="20" />
<br />
类别:<input type="text" name="class" size="20" />
<br />
提交:<input type="submit" name="submit" value="确定" />
</font>
  </form>
  </body>
</html>

XMLDao.jsp文件内容如下:
<%@ page language="java" import="java.util.*" pageEncoding="GBK" contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*" %>
<%@ page import="org.apache.crimson.tree.*" %>
<%@ page import="org.w3c.dom.*" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <base href="<%=basePath%>">
   
  <title>处理书目</title>
   
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">  
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

  </head>
  
  <body>
  <%
  String action = (String)request.getParameter("action");
 
  class trans {//字符转换类trans,避免中文出现乱码
  public String getStr(String str) {
  try {
  String temp1 = str;
  byte[] temp2 = temp1.getBytes("ISO-8859-1");
  String temp = new String(temp2);