You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by dg...@apache.org on 2003/04/09 04:28:24 UTC
cvs commit: jakarta-struts/src/example/org/apache/struts/webapp/example CheckLogonTag.java
dgraham 2003/04/08 19:28:24
Modified: src/example/org/apache/struts/webapp/example
CheckLogonTag.java
Log:
Check ServletContext for ModuleConfig instead of request for PR# 18794.
Revision Changes Path
1.8 +40 -31 jakarta-struts/src/example/org/apache/struts/webapp/example/CheckLogonTag.java
Index: CheckLogonTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/example/org/apache/struts/webapp/example/CheckLogonTag.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CheckLogonTag.java 18 Jan 2003 19:48:56 -0000 1.7
+++ CheckLogonTag.java 9 Apr 2003 02:28:24 -0000 1.8
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -63,6 +63,9 @@
package org.apache.struts.webapp.example;
+import java.io.IOException;
+
+import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
@@ -104,7 +107,7 @@
*/
public String getName() {
- return (this.name);
+ return (this.name);
}
@@ -116,7 +119,7 @@
*/
public void setName(String name) {
- this.name = name;
+ this.name = name;
}
@@ -126,7 +129,7 @@
*/
public String getPage() {
- return (this.page);
+ return (this.page);
}
@@ -138,7 +141,7 @@
*/
public void setPage(String page) {
- this.page = page;
+ this.page = page;
}
@@ -153,7 +156,7 @@
*/
public int doStartTag() throws JspException {
- return (SKIP_BODY);
+ return (SKIP_BODY);
}
@@ -166,27 +169,33 @@
* @exception JspException if a JSP exception has occurred
*/
public int doEndTag() throws JspException {
-
- // Is there a valid user logged on?
- boolean valid = false;
- HttpSession session = pageContext.getSession();
- if ((session != null) && (session.getAttribute(name) != null))
- valid = true;
-
- // Forward control based on the results
- if (valid)
- return (EVAL_PAGE);
- else {
- ModuleConfig config = (ModuleConfig) pageContext.getRequest()
- .getAttribute(org.apache.struts.Globals.MODULE_KEY);
- try {
- pageContext.forward(config.getPrefix() + page);
- } catch (Exception e) {
- throw new JspException(e.toString());
- }
- return (SKIP_PAGE);
- }
-
+
+ // Is there a valid user logged on?
+ boolean valid = false;
+ HttpSession session = pageContext.getSession();
+ if ((session != null) && (session.getAttribute(name) != null)) {
+ valid = true;
+ }
+
+ // Forward control based on the results
+ if (valid) {
+ return (EVAL_PAGE);
+ } else {
+ ModuleConfig config =
+ (ModuleConfig) pageContext.getServletContext().getAttribute(
+ org.apache.struts.Globals.MODULE_KEY);
+
+ try {
+ pageContext.forward(config.getPrefix() + page);
+ } catch (ServletException e) {
+ throw new JspException(e.toString());
+ } catch (IOException e) {
+ throw new JspException(e.toString());
+ }
+
+ return (SKIP_PAGE);
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org