| | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * Helfer fuer HTTP-Methoden |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | public String getAttrStr(Map attributes, String key, String defaultValue) { |
| | | Object value = attributes.get(key); |
| | | if(value instanceof String) { |
| | | return value.toString(); |
| | | } else { |
| | | return defaultValue; |
| | | } |
| | | } |
| | | |
| | | public File tryWelcomeFiles(HttpExchange e, String fName) { |
| | | String fileBase = e.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(); |
| | | String welcomeFiles = e.getHttpContext().getAttributes().get(FileHandler.ATTR_WELCOME_FILES).toString(); |
| | | String[] fileNames = welcomeFiles.split(FileHandler.STR_COMMA); |
| | | boolean notFound = true; |
| | | int i = -1; |
| | | File file = null; |
| | | while(notFound && ++i < fileNames.length) { |
| | | file = new File(fileBase, fName + fileNames[i]); |
| | | if(file.exists()) { |
| | | notFound = false; |
| | | String fileBase = e.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(); |
| | | Object welcomeFiles = e.getHttpContext().getAttributes().get(FileHandler.ATTR_WELCOME_FILES); |
| | | if(welcomeFiles instanceof String) { |
| | | String[] fileNames = welcomeFiles.toString().split(FileHandler.STR_COMMA); |
| | | int i = -1; |
| | | while(notFound && ++i < fileNames.length) { |
| | | file = new File(fileBase, fName + fileNames[i]); |
| | | if(file.exists()) { |
| | | notFound = false; |
| | | } |
| | | } |
| | | } |
| | | if(notFound) { |