Netbeans üzerinden Tomcat çalıştırırken alınan “127.0.0.1 iç yada dış komut çalıştırılabilir program yada toplu iş dosyası olarak tanınmıyor” hatası

Tomcat 8.0.30’da bin\catalina.bat dosyasında 195 ile 201. satırlar arasındaki aşağıdaki bloğu

:noJuliConfig
set "JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%"

...

:noJuliManager
set "JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%"

bununla değiştirin

:noJuliConfig
set JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%

...

:noJuliManager
set JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%

Kaynak: http://stackoverflow.com/a/26487192/1046569

Sharing session data between two contexts in tomcat 7

If you have two contexts, say /app1 and /app2 and you want to share session data between them you can do it by the following way:

  1. In context.xml set sessionCookiePath to / and set crossContext to true:
    <Context sessionCookiePath="/" crossContext="true">
  2. In both applications write this in web.xml:
    <filter>
    	<filter-name>userSessionFilter</filter-name>
    	<filter-class>myPackage.UserController</filter-class>
    </filter>
    <filter-mapping>
    	<filter-name>userSessionFilter</filter-name>
    	<url-pattern>/*</url-pattern>
    </filter-mapping>
  3. In the first application, create a class, say UserController, which implements Filter and in doFilter method:
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    	ServletContext sctx = ((HttpServletRequest) request).getSession().getServletContext();
    	String testStr = (String) sctx.getAttribute("attr");
    	if(testStr == null){
    		testStr = "test";
    		sctx.setAttribute("attr", testStr);
    	}
    	chain.doFilter(request, response);
    }
  4. In the second application, create a class, say UserController, which implements Filter and in doFilter method:
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    	ServletContext sctx = ((HttpServletRequest) request).getSession().getServletContext().getContext("/app1");
    	String testStr = (String) sctx.getAttribute("attr");
    	System.out.println("the value which set in first app: " + testStr);
    	chain.doFilter(request, response);
    }
  5. Now the testStr value which set in the first app’s UserController class, can be obtained by the second app’s UserController class..