String js=request.cookieValueForKey(JAVASCRIPT_ENABLED_COOKIE_NAME);
String js=null; try { request.cookieValueForKey(JAVASCRIPT_ENABLED_COOKIE_NAME); } catch (StringIndexOutOfBoundsException e) {  }
    public void awake() {        super.awake();        ERXExtensions.setSession(this);        ERXLocalizer.setCurrentLocalizer(localizer());        NSNotificationCenter.defaultCenter().postNotification(SessionWillAwakeNotification, this);        WORequest request=context()!=null ? context().request() : null;        // ENHANCEME: Should pull all of this browser detection out into it's own object with a factory        //		so that others can return their own subclasses of the browser object or parse the        //		the user-agent in a different manner. The factory could also maintain a cache of the        //		user-agent to browser object.        if (_browser==null && request!=null) {            String userAgent=(String)request.headerForKey("User-Agent");            isOmniweb=isICab=isIE=isNetscape=false;            if (userAgent!=null) {                if (userAgent.indexOf("OmniWeb")!=-1) {                    isOmniweb=true;                    _browser ="iCab";                } else if (userAgent.indexOf("iCab")!=-1) {                    isICab=true;                    _browser ="iCab";                } else if (userAgent.indexOf("MSIE")!=-1) {                    isIE=true;                    _browser ="MSIE";                } else if (userAgent.indexOf("Mozilla")!=-1) {                    isNetscape=true;                    _browser ="Netscape";                }                if (userAgent.indexOf("Win")!=-1) {                    isMac=isLinux=false;                    isWindows=true;                    platform="Windows";                } else if (userAgent.indexOf("Mac")!=-1) {                    isWindows=isLinux=false;                    isMac=true;                    platform="Mac";                } else if (userAgent.indexOf("Linux")!=-1) {                    isWindows=isMac=false;                    isLinux=true;                    platform="Linux";                }                if (userAgent.indexOf("5.0")!=-1 || userAgent.indexOf("5.5")!=-1) {                    isVersion3=isVersion4=false;                    isVersion5=true;                    version="5.0 or 5.5";                } else if (userAgent.indexOf("4.0")!=-1 ||                           userAgent.indexOf("4.5")!=-1 || userAgent.indexOf("4.7")!=-1) {                    isVersion3=isVersion5=false;                    isVersion4=true;                    version="4.0, 4.6, 4.7";                } else if (userAgent.indexOf("3.0")!=-1) {                    isVersion4=isVersion5=false;                    isVersion3=true;                    version="3.0";                }            }            if (_browser==null) _browser="Unknown";            if (cat.isDebugEnabled()) cat.debug("Browser="+_browser+" platform="+platform+" Version="+version);        }        if (request!=null && cat.isDebugEnabled()) cat.debug("Form values "+request.formValues());        // FIXME: Shouldn't be hardcoded form value.        if (request!=null && request.formValueForKey("javaScript")!=null) {            String js=(String)request.formValueForKey("javaScript");            if (cat.isDebugEnabled()) cat.debug("Received javascript form value "+js);            setJavaScriptEnabled(js!=null && js.equals("1") && (_browser==null || _browser.indexOf("Netscape3.")==-1));        }        if (request!=null && /* !_javaScriptInitialized */true) {            String js=request.cookieValueForKey(JAVASCRIPT_ENABLED_COOKIE_NAME);            if (js!=null) { // a friend sent us a cookie!                if (cat.isDebugEnabled()) cat.debug("Got JAVASCRIPT_ENABLED_COOKIE from a friend "+js);                setJavaScriptEnabled(js.equals("1") && (_browser==null || _browser.indexOf("Netscape3.")==-1));            }        }    }