java

Tomcat appBase and docBase

Tagged:  

While deploying JSF/Ajax application faced very strange problem. JSF mapping was working for files only in application root dir and in all other dirs was thrown such exception:

org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsf/core cannot be resolved in either web.xml or the jar files deployed with this application
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)

(Read more...)

Java/Python inverse regex

Tagged:  

Very simple but not very obvious inverse java/python regex:

^(.(?!(some text)))*$

So "String with some text inside" will give us:

>>> re.compile("^(.(?!(some text)))*$")
>>> r = regex.search(string)
# No match was found:
>>> r

And "String without":

>>> re.compile("^(.(?!(some text)))*$")
>>> r = regex.search(string)
>>> r
<_sre.SRE_Match object at 0xc70014791f56cff8>
>>> regex.match(string)
<_sre.SRE_Match object at 0xc70014791f56ce00>

Tada :)

Links:
http://www.pythonregex.com/ - online python regex test tool