Package javax.servlet.jsp

Examples of javax.servlet.jsp.PageContext


     * @throws IOException If something goes wrong.
     * @throws JspException If something goes wrong.
     */
    @Test
    public void testEvaluateWriterNull() throws JspException, IOException {
        PageContext pageContext = createMock(PageContext.class);
        Writer writer = createMock(Writer.class);

        expect(pageContext.getOut()).andReturn(null);

        replay(writer, pageContext);
        JspModelBody modelBody = new JspModelBody(null, pageContext);
        modelBody.evaluate(writer);
        verify(writer, pageContext);
View Full Code Here


     * @throws IOException If something goes wrong.
     * @throws JspException If something goes wrong.
     */
    @Test(expected = IOException.class)
    public void testEvaluateWriterException() throws JspException, IOException {
        PageContext pageContext = createMock(PageContext.class);
        JspFragment body = createMock(JspFragment.class);
        JspWriter writer = createMock(JspWriter.class);

        expect(pageContext.getOut()).andReturn(null);
        body.invoke(writer);
        expectLastCall().andThrow(new JspException());

        replay(body, pageContext, writer);
        try {
View Full Code Here

            }
        }

        HashMap model = new HashMap();
        try {
            PageContext pageContext = JspFactory.getDefaultFactory().getPageContext(this, request, response, "", false, 8192, true);

            // special hack for menu tag
            request.setAttribute("pageRequest", pageRequest);

            // populate the rendering model
View Full Code Here

        response.setContentType("text/html; charset=utf-8");
       
        // looks like we need to render content
        Map model = new HashMap();
        try {
            PageContext pageContext = JspFactory.getDefaultFactory().getPageContext(
                    this, request, response,"", false, 8192, true);
           
            // populate the rendering model
            Map initData = new HashMap();
            initData.put("request", request);
View Full Code Here

    /**
     * Creates and returns the test PageContext that will be used for
     * the tests.
     */
    static PageContext createTestContext() {
        PageContext ret = new PageContextImpl();

        // Create some basic values for lookups
        ret.setAttribute("val1a", "page-scoped1", PageContext.PAGE_SCOPE);
        ret.setAttribute("val1b", "request-scoped1", PageContext.REQUEST_SCOPE);
        ret.setAttribute("val1c", "session-scoped1", PageContext.SESSION_SCOPE);
        ret.setAttribute("val1d", "app-scoped1", PageContext.APPLICATION_SCOPE);

        // Create a bean
        {
            Bean1 b1 = new Bean1();
            b1.setBoolean1(true);
            b1.setByte1((byte) 12);
            b1.setShort1((short) -124);
            b1.setChar1('b');
            b1.setInt1(4);
            b1.setLong1(222423);
            b1.setFloat1((float) 12.4);
            b1.setDouble1(89.224);
            b1.setString1("hello");
            b1.setStringArray1(new String[]{
                    "string1",
                    "string2",
                    "string3",
                    "string4"
            });
            {
                List l = new ArrayList();
                l.add(new Integer(14));
                l.add("another value");
                l.add(b1.getStringArray1());
                b1.setList1(l);
            }
            {
                Map m = new HashMap();
                m.put("key1", "value1");
                m.put(new Integer(14), "value2");
                m.put(new Long(14), "value3");
                m.put("recurse", b1);
                b1.setMap1(m);
            }
            ret.setAttribute("bean1a", b1);

            Bean1 b2 = new Bean1();
            b2.setInt2(new Integer(-224));
            b2.setString2("bean2's string");
            b1.setBean1(b2);

            Bean1 b3 = new Bean1();
            b3.setDouble1(1422.332);
            b3.setString2("bean3's string");
            b2.setBean2(b3);
        }

        // Create the public/private beans
        {
            ret.setAttribute("pbean1", Factory.createBean1());
            ret.setAttribute("pbean2", Factory.createBean2());
            ret.setAttribute("pbean3", Factory.createBean3());
            ret.setAttribute("pbean4", Factory.createBean4());
            ret.setAttribute("pbean5", Factory.createBean5());
            ret.setAttribute("pbean6", Factory.createBean6());
            ret.setAttribute("pbean7", Factory.createBean7());
        }

        // Create the empty tests
        {
            Map m = new HashMap();
            m.put("emptyArray", new Object[0]);
            m.put("nonemptyArray", new Object[]{"abc"});
            m.put("emptyList", new ArrayList());
            {
                List l = new ArrayList();
                l.add("hello");
                m.put("nonemptyList", l);
            }
            m.put("emptyMap", new HashMap());
            {
                Map m2 = new HashMap();
                m2.put("a", "a");
                m.put("nonemptyMap", m2);
            }
            m.put("emptySet", new HashSet());
            {
                Set s = new HashSet();
                s.add("hello");
                m.put("nonemptySet", s);
            }
            ret.setAttribute("emptyTests", m);
        }

        return ret;
    }
View Full Code Here

     */
    @Override
    public void doTag() throws JspException {
        try {
            JspWriter out = getJspContext().getOut();
            PageContext context = (PageContext) getJspContext();
            String title = (String) context.getAttribute(_PAGE_SCOPE_TITLE_ID, PageContext.APPLICATION_SCOPE);
            out.print( title );
        } catch (IOException ex) {
            Logger.getLogger(TitleTag.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
View Full Code Here

    @Override
    public void doTag() throws JspException {
        JspWriter out = getJspContext().getOut();

        try {
            PageContext context = (PageContext) getJspContext();
            String content = (String) context.getAttribute(_PAGE_SCOPE_CONTENT_ID, PageContext.APPLICATION_SCOPE);

            out.println(content);

        } catch (java.io.IOException ex) {
            throw new JspException("Error in InsertContentTag tag", ex);
View Full Code Here

     */
    @Override
    public void doTag() throws JspException {
        try {

            PageContext pageContext = (PageContext) getJspContext();
            String templatePath = null;

            boolean ifIniting = false;
            try {
                Object bundleObj = (bundleObject == null) ? null : pageContext.getAttribute(bundleObject, PageContext.REQUEST_SCOPE);
                if (bundleObj == null) {
                    bundleObj = InstanceCreator.getInstance(className);
                    ifIniting = true;
                }
                AnnotationParser parser = new AnnotationParser(bundleObj, group);
                // 设定元素的默认值
                if (ifIniting) {
                    parser.settingDefaultValue();
                }
                ApplicationStyle style = settingAppStyle(pageContext);
                // 设定模板路径
                templatePath = style.getTemplatePath();
                // 设定许可
                Permission permissionImpl = null;
                if (isPermission()) {
                    permissionImpl = PermissionManager.getUserPermission();
                }
                ContentTemplate contentTemplate = (ContentTemplate) style.getTemplate(ContentTemplate.class);
                contentTemplate.setParser(parser);
                contentTemplate.setPermission(permissionImpl);
                String content = contentTemplate.content();

                settingContentScope(pageContext, content, parser.getTitle());
                template = (templatePath == null ? _BLANK : templatePath) + template;

                pageContext.include(template);
            } catch (AppException ex) {
                settingContentScope(pageContext, ex.getMessage(), _ERROR_TITLE_DISPLAY);
            }

        } catch (ServletException ex) {
View Full Code Here

  public static Map createPageScopeMap (PageContext pContext)

  {

    final PageContext context = pContext;

    return new EnumeratedMap ()

      {

  public Enumeration enumerateKeys ()

  {

    return context.getAttributeNamesInScope

      (PageContext.PAGE_SCOPE);

  }



  public Object getValue (Object pKey)

  {

    if (pKey instanceof String) {

      return context.getAttribute

        ((String) pKey,

         PageContext.PAGE_SCOPE);
View Full Code Here

  public static Map createRequestScopeMap (PageContext pContext)

  {

    final PageContext context = pContext;

    return new EnumeratedMap ()

      {

  public Enumeration enumerateKeys ()

  {

    return context.getAttributeNamesInScope

      (PageContext.REQUEST_SCOPE);

  }



  public Object getValue (Object pKey)

  {

    if (pKey instanceof String) {

      return context.getAttribute

        ((String) pKey,

         PageContext.REQUEST_SCOPE);
View Full Code Here

TOP

Related Classes of javax.servlet.jsp.PageContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.