open-menu closeme
Home
RetroComp icon
Retro Computing Articles Composition Notebooks 8bit
DevOps icon
Automation K8s Done Right
GenAI icon
Fatlama Newsletter Generative AI
Projects icon
Software Projects Arduino Misterio Esp8266 SQLite
Status
Links icon
GitHub LinkedIn
About
github linkedin rss
  • Java Session Fancy Printing

    calendar Mar 27, 2007 · 2 min read
     blog-objectsrootcom en  · http java list sage
     ·
    Share on: twitter facebook linkedin copy
    Java Session Fancy Printing

        public static final String convertToString(HttpServletRequest request) {
            StringBuffer msg = new StringBuffer();
            try {

                msg.append("*RequestURI:" + request.getRequestURI() + "\n");
                msg.append("*ContentType:" + request.getContentType() + "\n");

                msg.append("== Request Header\n");
                Enumeration headers = request.getHeaderNames();
                while (headers.hasMoreElements()) {
                    String headerName = "" + headers.nextElement();
                    msg.append(headerName + ":" + request.getHeader(headerName) + "\n");
                }
                msg.append("\n");
                
                Enumeration attr = request.getParameterNames();          
                
                ArrayList l = new ArrayList();
                String att;
                while (attr.hasMoreElements()) {
                    att = (String) attr.nextElement();
                    l.add(att + " -> " + request.getParameter(att));
                }
                
                msg.append("=== Request ( " + l.size() + " ) ===\n");
                Object a[] = l.toArray();
                Arrays.sort(a);
                for (int i = 0; i < a.length; i++) {
                    msg.append((String) a[i]);
                    msg.append("\n");
                }
                msg.append("===   ===   ===\n");
                
                // Process the Session
                HttpSession session = request.getSession();
                // msg.append("\n");
                
                Enumeration e = session.getAttributeNames();
                
                TreeMap t = new TreeMap();
                String k;
                while (e.hasMoreElements()) {
                    k = (String) e.nextElement();
                    Object oggetto;
                    try {
                        oggetto = session.getAttribute(k);
                    } catch (Throwable notSerializableException) {
                        oggetto = "NON DESERIALIZZABILE. Chiave:" + k;
                        
                    }
                    t.put(k, oggetto);
                }
                            
                Object orderedKeys[] = t.keySet().toArray();
                msg.append("=== Session  ( " + orderedKeys.length + " " + (usertempz != null ? "+ 1UT" : " NO UT!") + " )===\n");
                Object elem;

                for (int i = 0; i < orderedKeys.length; i++) {
                    elem = t.get(orderedKeys[i]);
                    msg.append(orderedKeys[i]);

                    msg.append("\t-> ");
                    if (elem != null) {
                        nicePrintSessionObj(msg, elem);
                    } else {
                        msg.append("null");
                    }
                    msg.append("\n");
                }
                return msg.toString();
            } catch (RuntimeException e) {
                return msg + "\nERR: Cannot print session/request!!" + e.getMessage();
            }
        }


    Read More
  • Site Update: Happy new editor!

    calendar Feb 28, 2007 · 1 min read
     blog-objectsrootcom en site  · ajax ant complex django easy editor framework good java javascript make news opinion pd script site touch vi web
     ·
    Share on: twitter facebook linkedin copy
    Site Update: Happy new editor!

    (First published on 2007-01-20)

    Hi all, ObjectsRoot now has correct story ordering ontags view!


    Read More
  • The Project Manager

    calendar Jun 28, 2006 · 1 min read
     blog-objectsrootcom en  · ant evil fini java linux programming project steve trouble ui vi
     ·
    Share on: twitter facebook linkedin copy
    The Project Manager

    Steve is not a normal solution provider.
    Steve is the final destination for Project Management troubles.


    Read More
    • ««
    • «
    • 10
    • 11
    • 12
    • 13
    • 14
    • »
    • »»

Recent Posts

  • Misterio Is Back
  • Netflix retro weird spirit
  • Yakuza Blues
  • FreeBSD on MacBook Mid 2009 with BroadCom WIFI

Latest comments

    Giovanni Giorgi

    Copyright 1999-  GIOVANNI GIORGI. All Rights Reserved

    to-top