1 17 18 package org.apache.tomcat.util.http; 19 20 import org.apache.tomcat.util.res.StringManager; 21 22 31 public class HttpMessages { 32 protected static StringManager sm = 34 StringManager.getManager("org.apache.tomcat.util.http.res"); 35 36 static String st_200=null; 37 static String st_302=null; 38 static String st_400=null; 39 static String st_404=null; 40 41 49 public static String getMessage( int status ) { 50 52 switch( status ) { 55 case 200: 56 if( st_200==null ) st_200=sm.getString( "sc.200"); 57 return st_200; 58 case 302: 59 if( st_302==null ) st_302=sm.getString( "sc.302"); 60 return st_302; 61 case 400: 62 if( st_400==null ) st_400=sm.getString( "sc.400"); 63 return st_400; 64 case 404: 65 if( st_404==null ) st_404=sm.getString( "sc.404"); 66 return st_404; 67 } 68 return sm.getString("sc."+ status); 69 } 70 71 78 public static String filter(String message) { 79 80 if (message == null) 81 return (null); 82 83 char content[] = new char[message.length()]; 84 message.getChars(0, message.length(), content, 0); 85 StringBuffer result = new StringBuffer (content.length + 50); 86 for (int i = 0; i < content.length; i++) { 87 switch (content[i]) { 88 case '<': 89 result.append("<"); 90 break; 91 case '>': 92 result.append(">"); 93 break; 94 case '&': 95 result.append("&"); 96 break; 97 case '"': 98 result.append("""); 99 break; 100 default: 101 result.append(content[i]); 102 } 103 } 104 return (result.toString()); 105 } 106 107 } 108 | Popular Tags |