1 23 24 package com.sun.enterprise.tools.admingui.servlet; 25 26 import com.sun.enterprise.tools.admingui.util.Util; 27 import com.sun.enterprise.tools.guiframework.exception.FrameworkException; 28 29 import java.io.*; 30 import java.util.*; 31 import java.net.URL ; 32 33 import javax.servlet.*; 34 import javax.servlet.http.*; 35 36 import java.io.InputStreamReader ; 37 38 39 42 public class HandleHelpFiles extends HttpServlet { 43 44 public void init(ServletConfig config) throws ServletException { 45 super.init(config); 46 } 47 48 public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { 49 doPost(req, res); 50 } 51 52 53 55 public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException { 56 String pathInfo = req.getPathInfo(); 57 String servletPath = req.getServletPath(); 58 59 URL htmlFile = null; 60 61 if(pathInfo == null || pathInfo.length() == 0) { 62 pathInfo = "/index.html"; 64 } 65 htmlFile = getClass().getClassLoader().getResource(servletPath.substring(1)+pathInfo); 66 67 if(htmlFile == null) { 68 htmlFile = getClass().getClassLoader().getResource(servletPath.substring(1)+"/notfound.html"); 70 } 71 72 try { 73 ServletOutputStream sout = res.getOutputStream(); 74 res.setCharacterEncoding("UTF-8"); 75 res.setContentType("text/html"); 76 BufferedReader bin = new BufferedReader 77 (new InputStreamReader (htmlFile.openStream(), "UTF-8")); 78 String line; 79 while ((line=bin.readLine())!=null) { 80 sout.println(line); 81 } 82 sout.close(); 83 } catch (IOException ex) { 84 Util.logWARNING("******HandleHelpFiles*******"+ex.getMessage()); 85 } 86 } 87 } 88 | Popular Tags |