Example usage for javax.servlet.jsp PageContext EXCEPTION

List of usage examples for javax.servlet.jsp PageContext EXCEPTION

Introduction

In this page you can find the example usage for javax.servlet.jsp PageContext EXCEPTION.

Prototype

String EXCEPTION

To view the source code for javax.servlet.jsp PageContext EXCEPTION.

Click Source Link

Document

Name used to store uncaught exception in ServletRequest attribute list and PageContext name table.

Usage

From source file:jp.terasoluna.fw.web.struts.action.SystemExceptionHandlerTest.java

/**
 * testExecute08()//from www .  j av  a  2  s.  c o  m
 * <br><br>
 * 
 * ??n
 * <br>
 * _?FC
 * <br><br>
 * l?F(?) ex:SystemException optionString=null<br>
 *         (?) eConfig:ExceptionConfig<br>
 *               ?ypathtB?[h"/errorPath.do"??z<br>
 *         (?) mapping:MockActionMapping<br>
 *         (?) formInstance:not null<br>
 *         (?) request:not null<br>
 *         (?) response:not null<br>
 *         (?) bundle:null<br>
 *         (?) resources:?yNGXg??z<br>
 *                Globals.MESSAGES_KEYMessageResourceMessageResources<br>
 *                MessageResources?o<br>
 *                 "aaaaa"?bZ?[WL?[o^<br>
 *                ?p<br>
 *         
 * <br>
 * l?F(l) ActionForward:tH??[h??F"/errorPath.do"<br>
 *         (?) request:NGXg??F<br>
 *                    PageContext.EXCEPTION?A<br>
 *                    SystemExceptiono^?B<br>
 *         (?) se:G?[?bZ?[W?F(null)<br>
 *         (?) ActionMessages?F"action.message.key"o^
 *                                    valuesnull
 *         (?) ?O:?yG?[?O?z<br>
 *                    ??bZ?[W?<br>
 *                    "sessionHash = " + sessionHash<br>
 *                    ExceptionUtil.getStackTrace(se)<br>
 *         
 * <br>
 * ?bZ?[W?Anull??B
 * <br>
 * 
 * @throws Exception ?\bh?O
 */
@SuppressWarnings("static-access")
public void testExecute08() throws Exception {
    // O??

    // VXeOnh
    SystemExceptionHandler handler = new SystemExceptionHandler();

    // VXeO
    SystemException e = new SystemException(new Exception(), "aaaaa");

    // O??
    ExceptionConfig eConfig = new ExceptionConfig();
    eConfig.setPath("/errorPath.do");
    eConfig.setKey("action.message.key");

    ActionMapping mapping = new ActionMapping();
    DynaActionForm form = new DynaActionForm();
    MockHttpServletRequest req = new MockHttpServletRequest();
    MockHttpServletResponse res = new MockHttpServletResponse();
    MockHttpSession session = new MockHttpSession();
    MockServletContext context = new MockServletContext();

    // MessageResources. returnNulltrue?
    MessageResourcesFactory factory = PropertyMessageResourcesFactory.createFactory();
    PropertyMessageResources requestResources = new PropertyMessageResources(factory,
            SystemExceptionHandler.class.getPackage().getName().replace('.', '/')
                    + "/SystemExceptionHandler_MessageResources01",
            true);

    // NGXgMessageResourceso^
    req.setAttribute(Globals.MESSAGES_KEY, requestResources);

    // T?[ubgReLXgNGXgQ??B
    session.setServletContext(context);
    req.setSession(session);

    // eXg{
    ActionForward forward = handler.execute(e, eConfig, mapping, form, req, res);

    // 

    // lmF
    assertEquals("/errorPath.do", forward.getPath());

    // NGXg??mF
    assertSame(e, req.getAttribute(PageContext.EXCEPTION));

    // VXeO?mF
    // getMessage()Pgetter?AnullG?[R?[hp?
    assertNull(UTUtil.getPrivateField(e, "message"));

    // ActionMessages?mF
    ActionMessages messages = (ActionMessages) req.getAttribute(Globals.ERROR_KEY);
    assertEquals(1, messages.size());
    Iterator it = messages.get();
    while (it.hasNext()) {
        ActionMessage actionMessage = (ActionMessage) it.next();
        assertEquals("action.message.key", actionMessage.getKey());
        assertNull(actionMessage.getValues());
    }

    // ?O?omF
    String sessionHash = RequestUtil.getSessionHash(req);
    assertTrue(LogUTUtil.checkError("sessionHash = " + sessionHash));
    assertTrue(LogUTUtil.checkError(ExceptionUtil.getStackTrace(e)));
}

From source file:jp.terasoluna.fw.web.struts.action.SystemExceptionHandlerTest.java

/**
 * testExecute09()/*www. j a va 2s .  co m*/
 * <br><br>
 * 
 * ??n
 * <br>
 * _?FA
 * <br><br>
 * l?F(?) ex:SystemException optionString=null<br>
 *         (?) eConfig:ExceptionConfigEx<br>
 *               ?ypathtB?[h"/errorPath.do"??z<br>
 *         (?) mapping:MockActionMapping<br>
 *         (?) formInstance:not null<br>
 *         (?) request:not null<br>
 *         (?) response:not null<br>
 *         (?) bundle:null<br>
 *         (?) resources:?yNGXg??z<br>
 *                Globals.MESSAGES_KEYMessageResourceMessageResources<br>
 *                MessageResources?o<br>
 *                 SystemExceptionHandlerTest.error.message.null = null<br>
 *                ?p<br>
 *         
 * <br>
 * l?F(l) ActionForward:tH??[h??F"/errorPath.do"<br>
 *                  O??W?[?FANVpXW?[<br>
 *         (?) request:NGXg??F<br>
 *                    PageContext.EXCEPTION?A<br>
 *                    SystemExceptiono^?B<br>
 *         (?) se:G?[?bZ?[W?F"error.msg"<br>
 *         (?) ActionMessages?F"action.message.key"o^
 *                                    valuesnull
 *         (?) ?O:?yG?[?O?z<br>
 *                    ??bZ?[W?<br>
 *                    "sessionHash = " + sessionHash<br>
 *                    ExceptionUtil.getStackTrace(se)<br>
 *         
 * <br>
 * O??ExceptionConfigEx???AO??W?[ANVpXW?[??B
 * <br>
 * 
 * @throws Exception ?\bh?O
 */
@SuppressWarnings("static-access")
public void testExecute09() throws Exception {
    // O??

    // VXeOnh
    SystemExceptionHandler handler = new SystemExceptionHandler();

    // VXeO
    SystemException e = new SystemException(new Exception(), "SystemExceptionHandlerTest.error.message");

    // O??
    ExceptionConfigEx eConfig = new ExceptionConfigEx();
    eConfig.setModule("error");
    eConfig.setPath("/errorPath.do");
    eConfig.setKey("action.message.key");

    ActionMapping mapping = new ActionMapping();
    DynaActionForm form = new DynaActionForm();
    MockHttpServletRequest req = new MockHttpServletRequest();
    MockHttpServletResponse res = new MockHttpServletResponse();
    MockHttpSession session = new MockHttpSession();
    MockServletContext context = new MockServletContext();

    // MessageResources
    MessageResourcesFactory factory = PropertyMessageResourcesFactory.createFactory();
    PropertyMessageResources requestResources = new PropertyMessageResources(factory,
            SystemExceptionHandler.class.getPackage().getName().replace('.', '/')
                    + "/SystemExceptionHandler_MessageResources01");

    // NGXgMessageResourceso^
    req.setAttribute(Globals.MESSAGES_KEY, requestResources);

    // T?[ubgReLXgNGXgQ??B
    session.setServletContext(context);
    req.setSession(session);

    // eXg{
    ActionForward forward = handler.execute(e, eConfig, mapping, form, req, res);

    // 

    // lmF
    assertEquals("/errorPath.do", forward.getPath());
    assertEquals("error", forward.getModule());

    // NGXg??mF
    assertSame(e, req.getAttribute(PageContext.EXCEPTION));

    // VXeO?mF
    assertEquals("O?bZ?[W", UTUtil.getPrivateField(e, "message"));

    // ActionMessages?mF
    ActionMessages messages = (ActionMessages) req.getAttribute(Globals.ERROR_KEY);
    assertEquals(1, messages.size());
    Iterator it = messages.get();
    while (it.hasNext()) {
        ActionMessage actionMessage = (ActionMessage) it.next();
        assertEquals("action.message.key", actionMessage.getKey());
        assertNull(actionMessage.getValues());
    }

    // ?O?omF
    String sessionHash = RequestUtil.getSessionHash(req);
    assertTrue(LogUTUtil.checkError("sessionHash = " + sessionHash));
    assertTrue(LogUTUtil.checkError(ExceptionUtil.getStackTrace(e)));
}

From source file:jp.terasoluna.fw.web.struts.action.SystemExceptionHandlerTest.java

/**
 * testExecute10()/*w  w w  . ja v  a 2  s . c o m*/
 * <br><br>
 * 
 * ??n
 * <br>
 * _?FC
 * <br><br>
 * l?F(?) ex:SystemException optionString=null<br>
 *         (?) eConfig:ExceptionConfig<br>
 *               ?ypathtB?[h"/errorPath.do"??z<br>
 *         (?) mapping:MockActionMapping<br>
 *         (?) formInstance:not null<br>
 *         (?) request:not null<br>
 *         (?) response:not null<br>
 *         (?) bundle:null<br>
 *         (?) resources:?yNGXg??z<br>
 *                Globals.MESSAGES_KEYMessageResourceMessageResources<br>
 *                MessageResources?o<br>
 *                 SystemExceptionHandlerTest.error.message.empty
 *                ?p<br>
 *         
 * <br>
 * l?F(l) ActionForward:tH??[h??F"/errorPath.do"<br>
 *         (?) request:NGXg??F<br>
 *                    PageContext.EXCEPTION?A<br>
 *                    SystemExceptiono^?B<br>
 *         (?) se:G?[?bZ?[W?F""<br>
 *         (?) ActionMessages?F"action.message.key"o^
 *                                    valuesnull
 *         (?) ?O:?yG?[?O?z<br>
 *                    ??bZ?[W?<br>
 *                    "sessionHash = " + sessionHash<br>
 *                    ExceptionUtil.getStackTrace(se)<br>
 *         
 * <br>
 * ?bZ?[W?A??B<br>
 * <br>
 * 
 * @throws Exception ?\bh?O
 */
@SuppressWarnings("static-access")
public void testExecute10() throws Exception {
    // O??

    // VXeOnh
    SystemExceptionHandler handler = new SystemExceptionHandler();

    // VXeO
    SystemException e = new SystemException(new Exception(), "SystemExceptionHandlerTest.error.message.empty");

    // O??
    ExceptionConfig eConfig = new ExceptionConfig();
    eConfig.setPath("/errorPath.do");
    eConfig.setKey("action.message.key");

    ActionMapping mapping = new ActionMapping();
    DynaActionForm form = new DynaActionForm();
    MockHttpServletRequest req = new MockHttpServletRequest();
    MockHttpServletResponse res = new MockHttpServletResponse();
    MockHttpSession session = new MockHttpSession();
    MockServletContext context = new MockServletContext();

    // MessageResources
    MessageResourcesFactory factory = PropertyMessageResourcesFactory.createFactory();
    PropertyMessageResources requestResources = new PropertyMessageResources(factory,
            SystemExceptionHandler.class.getPackage().getName().replace('.', '/')
                    + "/SystemExceptionHandler_MessageResources01");

    // NGXgMessageResourceso^
    req.setAttribute(Globals.MESSAGES_KEY, requestResources);

    // T?[ubgReLXgNGXgQ??B
    session.setServletContext(context);
    req.setSession(session);

    // eXg{
    ActionForward forward = handler.execute(e, eConfig, mapping, form, req, res);

    // 

    // lmF
    assertEquals("/errorPath.do", forward.getPath());

    // NGXg??mF
    assertSame(e, req.getAttribute(PageContext.EXCEPTION));

    // VXeO?mF
    assertEquals("", UTUtil.getPrivateField(e, "message"));

    // ActionMessages?mF
    ActionMessages messages = (ActionMessages) req.getAttribute(Globals.ERROR_KEY);
    assertEquals(1, messages.size());
    Iterator it = messages.get();
    while (it.hasNext()) {
        ActionMessage actionMessage = (ActionMessage) it.next();
        assertEquals("action.message.key", actionMessage.getKey());
        assertNull(actionMessage.getValues());
    }

    // ?O?omF
    String sessionHash = RequestUtil.getSessionHash(req);
    assertTrue(LogUTUtil.checkError("sessionHash = " + sessionHash));
    assertTrue(LogUTUtil.checkError(ExceptionUtil.getStackTrace(e)));
}

From source file:jp.terasoluna.fw.web.struts.action.SystemExceptionHandlerTest.java

/**
 * testExecute11()/*from w ww. j a v a2s.c  o  m*/
 * <br><br>
 * 
 * ?n
 * <br>
 * _?FA
 * <br><br>
 * l?F(?) ex:SystemException optionString={"1","22","333","4444","5555"}<br>
 *         (?) eConfig:ExceptionConfig<br>
 *               ?ypathtB?[h"/errorPath.do"??z<br>
 *         (?) mapping:not null<br>
 *               ?yinputtB?[h"/errorInput.do"??z
 *         (?) formInstance:not null<br>
 *         (?) request:not null<br>
 *         (?) response:not null<br>
 *         (?) bundle:null<br>
 *         (?) resources:?yNGXg??z<br>
 *                Globals.MESSAGES_KEYMessageResourceMessageResources<br>
 *                MessageResources?o<br>
 *                 SystemExceptionHandlerTest.error.message="O?bZ?[W"<br>
 *                }<br>
 *         
 * <br>
 * l?F(l) ActionForward:tH??[h??F"/errorPath.do"<br>
 *         (?) request:NGXg??F<br>
 *                    PageContext.EXCEPTION?FSystemException<br>
 *         (?) se:G?[?bZ?[W?F"O?bZ?[W"<br>
 *         (?) ActionMessages?F"action.message.key"o^
 *                                    values{"1","22","333","4444","5555"}
 *                                    
 *         (?) ?O:?yG?[?O?z<br>
 *                    ??bZ?[W?<br>
 *                    "sessionHash = " + sessionHash<br>
 *                    ExceptionUtil.getStackTrace(se)<br>
 *         
 * <br>
 * O??path??AANV}bsOinput?w?Apath?D??B
 * <br>
 * 
 * @throws Exception ?\bh?O
 */
@SuppressWarnings("static-access")
public void testExecute11() throws Exception {
    // O??

    // VXeOnh
    SystemExceptionHandler handler = new SystemExceptionHandler();

    String[] options = { "1", "22", "333", "4444", "5555" };
    // VXeO
    SystemException e = new SystemException(new Exception(), "SystemExceptionHandlerTest.error.message",
            options);

    // O??
    ExceptionConfig eConfig = new ExceptionConfig();
    eConfig.setPath("/errorPath.do");
    eConfig.setKey("action.message.key");

    // ANV}bsOInput??
    ActionMapping mapping = new ActionMapping();
    mapping.setInput("/errorInput.do");

    DynaActionForm form = new DynaActionForm();
    MockHttpServletRequest req = new MockHttpServletRequest();
    MockHttpServletResponse res = new MockHttpServletResponse();
    MockHttpSession session = new MockHttpSession();
    MockServletContext context = new MockServletContext();

    // MessageResources?
    MessageResourcesFactory factory = PropertyMessageResourcesFactory.createFactory();
    PropertyMessageResources requestResources = new PropertyMessageResources(factory,
            SystemExceptionHandler.class.getPackage().getName().replace('.', '/')
                    + "/SystemExceptionHandler_MessageResources01");

    // NGXgMessageResourceso^
    req.setAttribute(Globals.MESSAGES_KEY, requestResources);

    // T?[ubgReLXgNGXgQ??B
    session.setServletContext(context);
    req.setSession(session);

    // eXg{
    ActionForward forward = handler.execute(e, eConfig, mapping, form, req, res);

    // 

    // lmF
    assertEquals("/errorPath.do", forward.getPath());

    // NGXg?mF
    assertSame(e, req.getAttribute(PageContext.EXCEPTION));

    // O?mF
    assertEquals("O?bZ?[W", UTUtil.getPrivateField(e, "message"));

    // ActionMessages?mF
    ActionMessages messages = (ActionMessages) req.getAttribute(Globals.ERROR_KEY);
    assertEquals(1, messages.size());
    Iterator it = messages.get();
    while (it.hasNext()) {
        ActionMessage actionMessage = (ActionMessage) it.next();
        assertEquals("action.message.key", actionMessage.getKey());
        assertNotNull(actionMessage.getValues());
        assertEquals(options, actionMessage.getValues());
    }

    // ?O?omF
    String sessionHash = RequestUtil.getSessionHash(req);
    assertTrue(LogUTUtil.checkError("sessionHash = " + sessionHash));
    assertTrue(LogUTUtil.checkError(ExceptionUtil.getStackTrace(e)));
}