/** * Returns the title of the <code>WebPage</code> corresponding to the <code>RequestContext</code>. * The page may need to be partially executed. * * @param ctx */ public static String getTitle(WebPage page, RequestContext ctx) throws Exception { // Attach the request context to this thread RequestContext prevCtx = RequestContext.setCurrent(ctx); try { // Check authorization if (page.isAuthorized() == false) { throw new UnauthorizedException(); } page.init(); return page.getTitle(); } finally { // Restore the request context for this thread RequestContext.setCurrent(prevCtx); } }