01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.geronimo.test;
19:
20: import java.io.IOException;
21: import java.io.PrintWriter;
22:
23: import javax.servlet.http.HttpServlet;
24: import javax.servlet.http.HttpServletRequest;
25: import javax.servlet.http.HttpServletResponse;
26:
27: import javax.xml.stream.XMLInputFactory;
28: import javax.xml.stream.XMLOutputFactory;
29: import javax.xml.stream.XMLEventFactory;
30:
31: public class StaxServlet extends HttpServlet {
32:
33: public void doGet(HttpServletRequest theRequest,
34: HttpServletResponse theResponse) throws IOException {
35:
36: PrintWriter pw = theResponse.getWriter();
37:
38: theResponse.setContentType("text/html");
39: pw.println("<html><head><title>Servlet</title></head>");
40: pw.println("<body>");
41:
42: try {
43: XMLInputFactory inFactory = XMLInputFactory.newInstance();
44: pw.println(inFactory.getClass().getName());
45: StaxTest.testParse(inFactory);
46: XMLOutputFactory outFactory = XMLOutputFactory
47: .newInstance();
48: pw.println(outFactory.getClass().getName());
49: StaxTest.testStreamGenerate(outFactory);
50: XMLEventFactory eventFactory = XMLEventFactory
51: .newInstance();
52: pw.println(eventFactory.getClass().getName());
53: StaxTest.testEventGenerate(outFactory, eventFactory);
54: } catch (Exception e) {
55: e.printStackTrace();
56: IOException exception = new IOException("Error");
57: exception.initCause(e);
58: throw exception;
59: }
60:
61: pw.println("</body></html>");
62: }
63:
64: }
|