package yoonforh.servlet.util; /** * GetRequestURISSI.java * Copyright (c) 1999 Yoon Kyung Koo. All rights reserved. * * contact via yoonforh@yahoo.com * * first release date 1999/10/23 * version history * 1.0 1999/10/23 * first release * @version 1.0 1999/10/23 * @author Yoon Kyung Koo */ import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; // import sun.security.x509.*; /** * GetRequestURISSI class * @since JDK 1.1 */ public class GetRequestURISSI extends HttpServlet { // static initializer block static { // set KST time zone and KOREA locale Locale.setDefault(Locale.KOREA); TimeZone tz=new SimpleTimeZone(9*60*60*1000, "KST"); // tz.setID("KST"); TimeZone.setDefault(tz); } public void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { //value chosen to limit denial of service if (req.getContentLength() > 8*1024) { res.setContentType("text/html"); ServletOutputStream out = res.getOutputStream(); out.println("Too big"); out.println("

Error - content length >8k not "); out.println("

"); } else { doGet(req, res); } } public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html;charset=EUC_KR"); // PrintWriter out = res.getWriter(); ServletOutputStream out = res.getOutputStream(); out.println(convertToASCII(decodeURI(req.getRequestURI()))); } /** * decodeURI() * this method decodes encoded URI * @param uri string to be converted * @returns String converted * @throws java.io.UnsupportedEncodingException */ String decodeURI(String uri) throws UnsupportedEncodingException { if (uri == null) return null; char[] chars = uri.toCharArray(); byte[] bytes = new byte[chars.length]; int len=0; for (int i=0; i