You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by pi...@apache.org on 2001/07/20 04:36:10 UTC
cvs commit: jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes TroubleShooter.java
pier 01/07/19 19:36:10
Modified: webapps/examples/WEB-INF/classes TroubleShooter.java
Log:
Fixed some NullPointerExceptions and display aesthetics.
Revision Changes Path
1.2 +21 -16 jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes/TroubleShooter.java
Index: TroubleShooter.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/examples/WEB-INF/classes/TroubleShooter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TroubleShooter.java 2001/01/25 00:42:15 1.1
+++ TroubleShooter.java 2001/07/20 02:36:10 1.2
@@ -1,4 +1,4 @@
-/* $Id: TroubleShooter.java,v 1.1 2001/01/25 00:42:15 pier Exp $
+/* $Id: TroubleShooter.java,v 1.2 2001/07/20 02:36:10 pier Exp $
*
*/
@@ -21,6 +21,9 @@
}
public void printValue(PrintWriter out, String key, String val) {
+ if (val!=null) {
+ if (val.length()>255) val=val.substring(0,128)+" <i>(... more)</i>";
+ }
out.println(" <tr>");
out.println(" <td bgcolor=\"#cccccc\">"+key+"</td>");
out.println(" <td bgcolor=\"#ffffff\">"+val+"</td>");
@@ -160,7 +163,7 @@
printHeader(out,"Cookies in this request:");
Cookie[] cookies = request.getCookies();
- for (int i = 0; i < cookies.length; i++) {
+ if (cookies!=null) for (int i = 0; i < cookies.length; i++) {
Cookie cookie = cookies[i];
printValue(out,cookie.getName(),cookie.getValue());
}
@@ -181,21 +184,23 @@
printHeader(out,"Session information:");
SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss.SSS z");
- HttpSession session = request.getSession();
+ HttpSession session = request.getSession(false);
+ if (session!=null) {
printValue(out,"Requested Session Id:", request.getRequestedSessionId());
- printValue(out,"Current Session Id:", session.getId());
- printValue(out,"Current Time:", format.format(new Date()));
- printValue(out,"Session Created Time:", format.format(new Date(session.getCreationTime())));
- printValue(out,"Session Last Accessed Time:", format.format(new Date(session.getLastAccessedTime())));
- printValue(out,"Session Max Inactive Interval Seconds:", Integer.toString(session.getMaxInactiveInterval()));
- printVoid(out);
-
- printHeader(out,"Session values:");
- enum = session.getAttributeNames();
- while (enum.hasMoreElements()) {
- String key = (String) enum.nextElement();
- Object val = session.getAttribute(key);
- printValue(out,key,val.toString());
+ printValue(out,"Current Session Id:", session.getId());
+ printValue(out,"Current Time:", format.format(new Date()));
+ printValue(out,"Session Created Time:", format.format(new Date(session.getCreationTime())));
+ printValue(out,"Session Last Accessed Time:", format.format(new Date(session.getLastAccessedTime())));
+ printValue(out,"Session Max Inactive Interval Seconds:", Integer.toString(session.getMaxInactiveInterval()));
+ printVoid(out);
+
+ printHeader(out,"Session values:");
+ enum = session.getAttributeNames();
+ while (enum.hasMoreElements()) {
+ String key = (String) enum.nextElement();
+ Object val = session.getAttribute(key);
+ printValue(out,key,val.toString());
+ }
}
printVoid(out);