Hello!

I have a servlet EnterConstantServlet, which does some operation, which might 
fail. If that operation fails, I want that the user comes to a JSP page 
enterConstantFailed.jsp, where the error should be displayed.

If the operation completes successfully, the user should be redirected to JSP 
page enterConstantSuccess.jsp.

The servlet code is like shown below:


  | public class EnterConstantServlet extends HttpServlet {
  |     private static final String SUCCESS_PAGE = "enterConstantSuccess.jsp";
  |     private static final String FAILURE_PAGE = "enterConstantFailed.jsp";
  |     private static final long serialVersionUID = 1L;
  | 
  |     public EnterConstantServlet() {
  |             super();
  |             // TODO Auto-generated constructor stub
  |     }
  | 
  |     /**
  |      * @see 
javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, 
javax.servlet.http.HttpServletResponse)
  |      */
  |     @Override
  |     protected void doPost(HttpServletRequest req, HttpServletResponse resp) 
throws ServletException, IOException {
  |             Exception2TextualStackTrace func=null;
  |             PendingConstantHome home=null;
  |             PendingConstant pendingConstant=null;
  |         Context initial =null;
  |             String constant=null;
  |             Object objRef =null;
  |             
  |             /**
  |              * fetch name of the constant
  |              */
  |             constant=req.getParameter("constantName");
  |             
  |             /**
  |              * save constant in OpenCyc as pending constant
  |              */
  |             try
  |             {
  |             initial = new InitialContext();
  |             
  |             objRef = initial.lookup("java:comp/env/ejb/SimpleRoster");
  | 
  |             home = (PendingConstantHome)PortableRemoteObject.narrow(objRef, 
PendingConstantHome.class);
  |             
  |             pendingConstant = home.create();
  |             
  |             pendingConstant.setPendingConstantName(constant);
  |             
  |             resp.sendRedirect(SUCCESS_PAGE);
  |             }
  |             catch (Exception exception)
  |             {
  |                     func=new Exception2TextualStackTrace();
  |                     
  |                     System.out.println("failure reason: " + 
func.evaluate(exception));
  |                     
  |             resp.addHeader(FAILURE_REASON, func.evaluate(exception));
  |                     resp.sendRedirect(FAILURE_PAGE);
  |             }
  |     }
  | }
  | 

Note: The return value of

func.evaluate(exception)

is not null. I see this in the log file of JBoss.

I have a problem - the failure reason (parameter FAILURE_REASON in the above 
code) is NOT displayed in enterConstantFailed.jsp.

enterConstantFailed.jsp looks like shown below:


  | <?xml version="1.0" encoding="UTF-8" ?>
  | <%--
  |   $Author: user $
  |   $Revision: 1.2 $
  |   $Date: 2006/04/11 20:51:35 $
  |   $Id: enterConstantFailed.jsp,v 1.2 2006/04/11 20:51:35 user Exp $
  |   $Log: enterConstantFailed.jsp,v $
  |   Revision 1.2  2006/04/11 20:51:35  user
  |   Added routine for displaying failure reason.
  | 
  |   Revision 1.1  2006/04/11 20:29:58  user
  |   Initial commit.
  | 
  | --%>
  | <%@ page language="java" contentType="text/html; charset=UTF-8"
  |     pageEncoding="UTF-8"%>
  | <%@ include file="header.jsp" %>
  | 
  | <h1>????????? ?????? ??? ????? ?????????</h1>
  | <p>????? ?????? ???????? ????.</p>
  | <pre><%= 
request.getParameter(intranet.dapissarenko.com.WriteImageServlet.FAILURE_REASON)
 %></pre>
  | 
  | <%@ include file="footer.jsp" %>
  | 

What should I do in order for the failure reason to be displayed in 
enterConstantFailed.jsp?

Thanks in advance

Dmitri Pissarenko

PS: This is the code of header.jsp:

  | <?xml version="1.0" encoding="UTF-8" ?>
  | <!--
  |   $Author: user $
  |   $Revision: 1.2 $
  |   $Date: 2006/04/04 21:39:40 $
  |   $Id: header.jsp,v 1.2 2006/04/04 21:39:40 user Exp $
  |   $Log: header.jsp,v $
  |   Revision 1.2  2006/04/04 21:39:40  user
  |   Added link to sanSanych.jsp.
  | 
  |   Revision 1.1  2006/04/02 22:56:57  user
  |   Initial commit.
  | 
  | -->
  | <%@ page language="java" contentType="text/html; charset=UTF-8"
  |     pageEncoding="UTF-8"%>
  | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
  | <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="ru" lang="ru-RU">
  |   <head>
  |     <meta http-equiv="content-type" content="application/xhtml+xml; 
charset=UTF-8" />
  |     <meta name="author" content="haran" />
  |     <meta name="generator" content="haran" />
  | 
  |     <link rel="stylesheet" type="text/css" href="prosimii-screen.css" 
media="screen, tv, projection" title="Default" />
  |     <link rel="stylesheet alternative" type="text/css" 
href="prosimii-print.css" media="screen" title="Print Preview" />
  |     <link rel="stylesheet" type="text/css" href="prosimii-print.css" 
media="print" />
  | 
  |     <title>?????????? ???? ??????? ?????????</title>
  |   </head>
  | 
  |   <body>
  |     <!-- For non-visual user agents: -->
  |       <div id="top"><a href="#main-copy" class="doNotDisplay 
doNotPrint">Skip to main content.</a></div>
  | 
  |     <!-- ##### Header ##### -->
  | 
  |     <div id="header">
  |       <div class="superHeader">
  |         <span></span>
  |         <a href="http://dapissarenko.com"; title="Dmitri 
Pissarenko">??????????? ???? ??????? ?????????</a>
  |       </div>
  | 
  |       <div class="midHeader">
  |         <h1 class="headerTitle" lang="la">??????? ?????????</h1>
  |         <div class="headerSubTitle">
  |           ?????????? ????
  |         </div>
  | 
  |         <br class="doNotDisplay doNotPrint" />
  | 
  | 
  |       </div>
  | 
  |       <div class="subHeader">
  |         <span class="doNotDisplay">Navigation:</span>
  |         <a href="enterTime.jsp">?????? ????? ??????</a> |
  |         <a href="sanSanych.jsp">??? ?????</a> |
  |         <a href="./index.html">?????????? ???????????</a>
  |       </div>
  |     </div>
  | 
  |     <!-- ##### Main Copy ##### -->
  | 
  |     <div id="main-copy">
  |       <div class="rowOfBoxes">
  |         <div class="twoThirds noBorderOnLeft">
  | 

PPS: This is the code of footer.jsp:


  | <?xml version="1.0" encoding="UTF-8" ?>
  | <!--
  |   $Author: user $
  |   $Revision: 1.2 $
  |   $Date: 2006/04/02 23:07:06 $
  |   $Id: footer.jsp,v 1.2 2006/04/02 23:07:06 user Exp $
  |   $Log: footer.jsp,v $
  |   Revision 1.2  2006/04/02 23:07:06  user
  |   Fixed encoding problems.
  | 
  |   Revision 1.1  2006/04/02 22:56:57  user
  |   Initial commit.
  | 
  | -->
  | <%@ page language="java" contentType="text/html; charset=UTF-8"
  |     pageEncoding="UTF-8"%>
  |     <!-- ##### Main text comes here ##### -->
  |     
  |         </div>
  |       </div>
  |     </div>
  | 
  |     <!-- ##### Footer ##### -->
  | 
  |     <div id="footer">
  |       <span class="doNotPrint">
  |         ?? ???? ???????? ?????? ???? ???????? ?????? ?? ????
  |         <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a><br />
  |       </span>
  | 
  |       <strong>???????? ??????? ยป</strong> <%= 
java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.DEFAULT, 
java.text.DateFormat.DEFAULT, new java.util.Locale("ru")).format(new 
java.util.Date())  %>
  |     </div>
  |   </body>
  | </html>
  | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3936854#3936854

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3936854


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to