All pastes #822684 Raw Edit

Unbenannt

public java v1 · immutable
·published 2007-12-18 21:56 UTC
rendered paste body
	public String encodeUrlRegex(String url)	{		String recoded = "";				Request request = (Request)getConnection().getRequest();				if (request == null)			return url;				Session session = (Session)request.getSession();				if (session == null)			return url;				if (url != null)		{			for (String handler : WebHandler.getInstance().getHandlers())			{				int lastPos = 0;								if (!WebHandler.getInstance().getHandler(handler).needRewriteURL())					continue;								String patter 	= "(?:[\"|']{1})/{1}+"+handler+"{1}[^\"'?#]{0,}";				Pattern pattern = Pattern.compile(patter);				Matcher matcher = pattern.matcher(url);								while (matcher.find())				{					recoded += url.substring(lastPos, matcher.start()+1);					String match = matcher.group().substring(1);										if (match.endsWith("/"))						recoded += match + "sessionid/" + session.getId();					else						recoded += match + "/sessionid/" + session.getId();										lastPos = matcher.end();				}				if (recoded.length() > 0)				{					recoded += url.substring(lastPos, url.length());					url = recoded;				}								recoded = "";				lastPos = 0;			}		}				return url;	}