1 2 24 25 26 27 28 29 package com.lutris.appserver.server.httpPresentation; 30 import java.net.URLEncoder ; 31 32 33 38 abstract public class PageRedirectException extends Error { 39 42 private String url; 43 44 47 private boolean urlHasArgs = false; 48 49 52 protected String encoding = ""; 53 54 62 protected PageRedirectException(String url) { 63 this.url = url; 64 urlHasArgs = (url.lastIndexOf('?') >= 0); 65 this.encoding = "iso-8859-1"; } 67 68 77 protected PageRedirectException(String url, String encoding) { 78 this.url = url; 79 urlHasArgs = (url.lastIndexOf('?') >= 0); 80 this.encoding = encoding; 81 } 82 83 84 90 public void addArgument( String name, 91 String value ) { 92 try { 93 StringBuffer argStr = new StringBuffer (); 94 if ( urlHasArgs ) { 95 argStr.append( "&" ); 96 } 97 else { 98 argStr.append( "?" ); 99 } 100 argStr.append( URLEncoder.encode( name, encoding ) ); 101 if ( value != null ) { 102 argStr.append( "=" ); 103 argStr.append( URLEncoder.encode( value, encoding ) ); 104 } 105 url += argStr; 106 urlHasArgs = true; 107 } 108 catch ( Exception e ) { 109 e.printStackTrace(); 110 } 111 112 } 113 114 119 public String getUrl() { 120 return url; 121 } 122 123 127 public String getEncoding() { 128 return encoding; 129 } 130 131 } 132 | Popular Tags |