01: /* Jsps.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Mon Jul 23 14:11:09 2007, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.jsp.zul.impl;
20:
21: import javax.servlet.jsp.JspContext;
22: import javax.servlet.jsp.PageContext;
23: import javax.servlet.jsp.JspException;
24:
25: /**
26: * Jsp Utilities.
27: *
28: * @author tomyeh
29: */
30: public class Jsps {
31: private Jsps() {
32: }
33:
34: /** Reteurns the page context of the specified JSP context.
35: */
36: public static final PageContext getPageContext(JspContext jspctx)
37: throws JspException {
38: if (jspctx instanceof PageContext)
39: return (PageContext) jspctx;
40: try {
41: final PageContext pgctx = (PageContext) jspctx
42: .getExpressionEvaluator().evaluate(
43: "${pageContext}", PageContext.class, null,
44: null);
45: if (pgctx != null)
46: return pgctx;
47: throw new JspException(
48: "Unable to retrieve PageContext from " + jspctx);
49: } catch (javax.servlet.jsp.el.ELException ex) {
50: throw new JspException(
51: "Unable to retrieve PageContext from " + jspctx, ex);
52: }
53: }
54: }
|