01: /**********************************************************************************
02: * $URL$
03: * $Id$
04: ***********************************************************************************
05: *
06: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the"License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.tool.assessment.ui.servlet.qti;
21:
22: import java.io.IOException;
23: import java.io.PrintWriter;
24: import javax.servlet.ServletException;
25: import javax.servlet.http.HttpServlet;
26: import javax.servlet.http.HttpServletRequest;
27: import javax.servlet.http.HttpServletResponse;
28:
29: import org.apache.commons.logging.Log;
30: import org.apache.commons.logging.LogFactory;
31:
32: import org.sakaiproject.tool.assessment.ui.bean.qti.XMLDisplay;
33: import org.sakaiproject.tool.assessment.ui.listener.util.ContextUtil;
34:
35: /**
36: * <p>Title: Samigo</p>
37: * <p>Description: Sakai Assessment Manager Export to QTI</p>
38: * <p>Copyright: Copyright (c) 2004 Sakai Project</p>
39: * <p>Organization: Sakai Project</p>
40: * @author Ed Smiley
41: * @version $Id: ShowMediaServlet.java 244 2005-06-24 04:06:14Z daisyf@stanford.edu $
42: */
43:
44: public class ShowQTIServlet extends HttpServlet {
45: /**
46: *
47: */
48: private static final long serialVersionUID = 3855448630209417469L;
49: private static Log log = LogFactory.getLog(ShowQTIServlet.class);
50:
51: //private String xmlData;
52:
53: /**
54: * passthu to post
55: * @param req
56: * @param res
57: * @throws ServletException
58: * @throws IOException
59: */
60: public void doGet(HttpServletRequest req, HttpServletResponse res)
61: throws ServletException, IOException {
62: doPost(req, res);
63: }
64:
65: /**
66: * Get the faces context and display the contents of the XMLDisplay bean
67: * @param req
68: * @param res
69: * @throws ServletException
70: * @throws IOException
71: */
72: public void doPost(HttpServletRequest req, HttpServletResponse res)
73: throws ServletException, IOException {
74: XMLDisplay xmlDisp = (XMLDisplay) ContextUtil
75: .lookupBeanFromExternalServlet("xml", req, res);
76: String xml = xmlDisp.getXml();
77: String fileName = xmlDisp.getName() + "." + xml;
78:
79: res.setHeader("Content-Disposition", "inline" + ";filename=\""
80: + fileName + "\";");
81: PrintWriter out = res.getWriter();
82: log.info("debug show qti:");
83: log.info("xml");
84: out.print(xml);
85: }
86:
87: }
|