Monday, August 10, 2020

Cookies sharing in Spring boot applications

    @GetMapping("/greeting")
    public String greeting(HttpSession session, HttpServletRequest request, HttpServletResponse response, @RequestParam(name="name", required=false, defaultValue="World") String name, Model model) {
        model.addAttribute("name", name);
        System.out.println(session);
        System.out.println(request);
        for (Cookie cookie : request.getCookies()) {
            System.out.println(cookie.getName() + " " + cookie.getValue());
        }
        Cookie uiColorCookie = new Cookie("color2", "red2");
        uiColorCookie.setDomain("localhost");
        uiColorCookie.setPath("/");
        response.addCookie(uiColorCookie);
        return "greeting";
    }

the code of the 2 applications is: 

https://github.com/vernetto/demosession01 

https://github.com/vernetto/demosession02 

http://localhost:8181/books01/greeting?name=pirla 

http://localhost:8282/books02/greeting?name=pirla 

In Firefox, use F12 and "storage" to examine cookies. 

Using embedded Tomcat, the session turns out to be:

org.apache.catalina.session.StandardSessionFacade https://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/session/StandardSessionFacade.html



Sunday, June 21, 2020

Oracle monitoring session


https://orahow.com/find-long-running-queries-in-oracle/

http://www.dba-oracle.com/t_find_long_running_sql_queries.htm

WITH blocked_resources AS (select id1 ,id2 ,SUM(ctime) as blocked_secs ,COUNT(1) as blocked_count ,type from v$lock where request > 0 group by type,id1,id2 ) ,blockers AS (select L.id1, L.id2, L.type, L.sid ,BR.blocked_secs ,BR.blocked_count from v$lock L ,blocked_resources BR where BR.type = L.type and BR.id1 = L.id1 and BR.id2 = L.id2 and L.lmode > 0 and L.block <> 0 ) select /*+ MERGE(@"SEL$22") MERGE(@"SEL$109DB78D") MERGE(@"SEL$5") MERGE(@"SEL$38") MERGE(@"SEL$470E2127") MERGE(@"SEL$7286615E") MERGE(@"SEL$62725911") MERGE(@"SEL$2EC965E0") MERGE(@"SEL$C8360722") MERGE(@"SEL$874CA85A") MERGE(@"SEL$74A24351") MERGE(@"SEL$71D7A081") MERGE(@"SEL$7") MERGE(@"SEL$24") CARDINALITY(@"SEL$AF73C875" "S"@"SEL$4" 1000) CARDINALITY(@"SEL$AF73C875" "R"@"SEL$4" 1000) */ B.id1||'_'||B.id2||'_'||S.sid||'_'||S.serial# as id ,'SID,SERIAL:'||S.sid||','||S.serial#||',LOCK_TYPE:'||B.type||',PROGRAM:'||S.program||',MODULE:'||S.module||',ACTION:'||S.action||',MACHINE:'||S.machine||',OSUSER:'||S.osuser||',USERNAME:'||S.username as info ,B.blocked_secs ,B.blocked_count from v$session S ,blockers B where B.sid = S.sid;


Recommended the use of TOAD for DBA (Database browser)