Я использовал это на нескольких проектах, я не полагаю, что столкнулся с проблемами, но я уверен, что это не является исчерпывающим:
$text = preg_replace(
'#((https?|ftp)://(\S*?\.\S*?))([\s)\[\]{},;"\':<]|\.\s|$)#i',
"'<a href=\"$1\" target=\"_blank\">$3</a>$4'",
$text
);
большая часть случайного спама в конце должна справиться с ситуациями как http://domain.com.
в предложении (чтобы не соответствовать запаздывающему периоду). Я уверен, что это могло быть очищено, но так как это работало. Я более или менее только что скопировал его от проекта до проекта.
В настоящее время Restlet не поддерживает JSP напрямую. Их трудно обрабатывать за пределами контейнера сервлетов.
Ответ от «23 апреля 2009 года; 15:02» в ветке описывает, как вы могли бы взломать:
if (request instanceof HttpRequest &&
((HttpRequest) request).getHttpCall() instanceof ServletCall) {
ServletCall httpCall = (ServletCall) ((HttpRequest) request).getHttpCall();
// fetch the HTTP dispatcher
RequestDispatcher dispatcher = httpCall.getRequest().getRequestDispatcher("representation.jsp");
HttpServletRequest proxyReq = new HttpServletRequestWrapper(httpCall.getRequest());
// Overload the http response stream to grab the JSP output into a dedicated proxy buffer
// The BufferedServletResponseWrapper is a custom response wrapper that 'hijacks' the
// output of the JSP engine and stores it on the side instead of forwarding it to the original
// HTTP response.
// This is needed to avoid having the JSP engine mess with the actual HTTP stream of the
// current request, which must stay under the control of the restlet engine.
BufferedServletResponseWrapper proxyResp = new BufferedServletResponseWrapper(httpCall.getResponse());
// Add any objects to be encoded in the http request scope
proxyReq.setAttribute("myobjects", someObjects);
// Actual JSP encoding
dispatcher.include(proxyReq, proxyResp);
// Return the content of the proxy buffer
Representation rep = new InputRepresentation(proxyResp.toInputStream(),someMediaType);
Источник BufferedServletResponseWrapper опубликован парой записей позже.
Похоже на простую конфигурацию web.xml.
<servlet>
<servlet-name>contactServlet</servlet-name>
<jsp-file>/contact.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>contactServlet</servlet-name>
<url-pattern>/contact</url-pattern>
</servlet-mapping>
Это работает без рестлета в App-Engine. Но как только я включаю Restlet, он не работает, если я устанавливаю свой URL-шаблон Reslet на «/ *»