@SuppressWarnings("checkstyle:MagicNumber")
    @RequestMapping(method = RequestMethod.GET)
    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {

        Subject subject = SecurityUtils.getSubject();
        Session session = null;

        if (subject != null) {
            session = subject.getSession();
        }
        if (session == null) {
            String msg = "Expected a non-null Shiro session.";
            throw new IllegalArgumentException(msg);
        }

        StringBuilder sb = new StringBuilder();
        sb.append("http://");
        sb.append(request.getServerName());
        if (request.getServerPort() != 80) {
            sb.append(":");
            sb.append(request.getServerPort());
        }
        sb.append(request.getContextPath());

        // prevent JNLP caching by setting response headers
        response.setHeader("cache-control", "no-cache");
        response.setHeader("pragma", "no-cache");

        Map<String, Object> model = new HashMap<String, Object>();
        model.put("codebaseUrl", sb.toString());
        model.put("sessionId", session.getId());
        return new ModelAndView(jnlpView, model);
    }
Controller used to dynamically build a JNLP file used to launch the Shiro
Spring WebStart sample application.

@since 0.1
samples/spring-mvc/src/main/java/org/apache/shiro/samples/spring/web/JnlpController.java