String wsName = session.getWebService().getName(); String wsURL  = session.getWebService().getUrl();
wsName = session.getWebService().getName(); wsURL  = session.getWebService().getUrl(); }
    private Template genLoginTemplate(HttpServletRequest request, HttpServletResponse response, Context context, Session session, String errorType) throws ParseErrorException, ResourceNotFoundException, MissingResourceException, Exception {        String bundleName = "login";        String acceptLanguage = request.getHeader("Accept-Language");        String sessionID = null;        ResourceBundle bundle = null;        ResourceBundle fallback = null;        if (session != null)            sessionID = session.getID();        if (acceptLanguage == null || acceptLanguage.equals(""))             acceptLanguage = "no";        StringTokenizer tokenizer = new StringTokenizer(acceptLanguage, ",");        Locale locale = null;                /* Find fallback resource bundle. */        try {            fallback = ResourceBundle.getBundle(bundleName, new Locale("bogus"));        }        catch (MissingResourceException e) {            /* No fallback */        }                    /* Parse Accept-Language and find matching resource bundle */        while (tokenizer.hasMoreTokens()) {            String lang = tokenizer.nextToken();            int index;            /* Languages are devided by ";" */            if ((index = lang.indexOf(";")) != -1) {                lang = lang.substring(0, index);            }            lang = lang.trim();            /* Language and country is devided by "-" (optional) */            if ((index = lang.indexOf("-")) != -1) {                lang = lang.substring(0, index);            }                                    locale = new Locale(lang);            bundle = ResourceBundle.getBundle(bundleName, locale);            /* Abort search if a bundle (not fallback) is found */            if (bundle != fallback)                 break;            /* About search if the fallback bundle is actually requested */            else if (bundle == fallback && locale.getLanguage().equals(Locale.getDefault().getLanguage()))                break;        }        /* Should never happen, but just in case. */        if (bundle == null)            bundle = ResourceBundle.getBundle(bundleName, new Locale("no"));        if (session != null) {            String wsName = session.getWebService().getName();            String wsURL  = session.getWebService().getUrl();            /* Set template-variables from properties */            for (Enumeration e = bundle.getKeys(); e.hasMoreElements();) {                String key = (String) e.nextElement();                String value = bundle.getString(key);                int index;                            if ((index = value.indexOf("WS_NAME")) != -1) {                    // TODO: Read name+url from web service data.                    value = value.substring(0, index)+"<A href=\""+wsURL+"\">"+wsName+"</A>"+value.substring(index+7, value.length());                }                                context.put(key, value);            }                }        /* Set or reset error messages */        if (errorType != null) {            context.put("errorMessage", bundle.getString("error_"+errorType));            context.put("errorDescription", bundle.getString("error_"+errorType+"_desc"));        }             else {            context.remove("errorMessage");            context.remove("errorDescription");        }        /* If no sessionID then remove loginURL */        if (sessionID != null)             context.put("loginURL", loginURL+"?id="+sessionID);                else             context.remove("loginURL");        return getTemplate("login.vtl");    }