1    package com.instantbank.lettertemplate.control.util;
2    
3    import java.util.StringTokenizer;
4    
5    import javax.servlet.http.HttpServletRequest;
6    import javax.servlet.http.HttpServletResponse;
7    import javax.servlet.ServletContext;
8    import javax.servlet.http.HttpSession;
9    import javax.servlet.ServletException;
10   
11   import com.instantbank.lettertemplate.control.util.WebKeys;
12   import com.instantbank.common.utilcomponents.Debug;
13   
14   /**
15    *  This utility class for web tier components (namely Java Server Pages and
16    *  JavaBeans). This class provides a central location to do specialized
17    *  formatting in both a default and a locale specific manner.
18    *
19    * @author Instant-bank (Consuelo Franky)
20    * @created September 2002
21    */
22   public final class JSPUtil extends Object {
23   
24     //access to eventCounter is only through the
25     //accessor method getEventId() :
26   
27     private static int eventCounter;
28   
29   
30     /**
31      *  generate unique sequencer
32      *
33      * @return The eventId value
34      */
35     public static int getEventId() {
36       return eventCounter++;
37     }
38   
39   
40   
41     /**
42      *  method for putting in the current request, the message and the stacktrace
43      *  of an exception previously catched
44      *
45      * @param request current request
46      * @param problem String with the format: messageString|stackTraceString
47      */
48     public static void putProblemInRequest
49       (HttpServletRequest request, String problem) {
50   
51       StringTokenizer problemTokens = new StringTokenizer(problem, "|");
52       String theProblem = problemTokens.nextToken();
53       String theStackTrace = problemTokens.nextToken();
54       request.setAttribute(WebKeys.ExceptionOcurred, theProblem);
55       request.setAttribute(WebKeys.ExceptionStackTrace, theStackTrace);
56   
57       try {
58         StringTokenizer theProblemTokens = new StringTokenizer(theProblem, ".:");
59         String mainMessage = theProblemTokens.nextToken();
60         request.setAttribute(WebKeys.MainMessage, mainMessage);
61       }
62       catch(Exception e) {
63         request.setAttribute(WebKeys.MainMessage, "");
64       }
65     }
66   
67   }
68   
69