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/07/14 02:04:44 UTC
cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/bean HeaderTag.java
dgraham 2003/07/13 17:04:44
Modified: src/share/org/apache/struts/taglib/bean HeaderTag.java
Log:
Fixed formatting.
Revision Changes Path
1.10 +40 -43 jakarta-struts/src/share/org/apache/struts/taglib/bean/HeaderTag.java
Index: HeaderTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/HeaderTag.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- HeaderTag.java 22 Sep 2002 06:32:45 -0000 1.9
+++ HeaderTag.java 14 Jul 2003 00:04:44 -0000 1.10
@@ -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
@@ -59,19 +59,18 @@
*
*/
-
package org.apache.struts.taglib.bean;
-
import java.util.ArrayList;
import java.util.Enumeration;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
+
import org.apache.struts.util.MessageResources;
import org.apache.struts.util.RequestUtils;
-
/**
* Define a scripting variable based on the value(s) of the specified
* header received with this request.
@@ -79,13 +78,10 @@
* @author Craig R. McClanahan
* @version $Revision$ $Date$
*/
-
public class HeaderTag extends TagSupport {
-
// ------------------------------------------------------------- Properties
-
/**
* The name of the scripting variable that will be exposed as a page
* scope attribute.
@@ -100,14 +96,12 @@
this.id = id;
}
-
/**
* The message resources for this package.
*/
protected static MessageResources messages =
- MessageResources.getMessageResources
- ("org.apache.struts.taglib.bean.LocalStrings");
-
+ MessageResources.getMessageResources(
+ "org.apache.struts.taglib.bean.LocalStrings");
/**
* Return an array of header values if <code>multiple</code> is non-null.
@@ -122,7 +116,6 @@
this.multiple = multiple;
}
-
/**
* The name of the header whose value is to be exposed.
*/
@@ -136,7 +129,6 @@
this.name = name;
}
-
/**
* The default value to return if no header of the specified name is found.
*/
@@ -150,10 +142,8 @@
this.value = value;
}
-
// --------------------------------------------------------- Public Methods
-
/**
* Retrieve the required property and expose it as a scripting variable.
*
@@ -163,41 +153,49 @@
// Deal with a single header value
if (multiple == null) {
- String value =
- ((HttpServletRequest) pageContext.getRequest()).getHeader(name);
- if ((value == null) && (this.value != null))
+ String value =
+ ((HttpServletRequest) pageContext.getRequest()).getHeader(name);
+
+ if ((value == null) && (this.value != null)) {
value = this.value;
- if (value == null) {
- JspException e = new JspException
- (messages.getMessage("header.get", name));
+ }
+
+ if (value == null) {
+ JspException e =
+ new JspException(messages.getMessage("header.get", name));
RequestUtils.saveException(pageContext, e);
throw e;
}
- pageContext.setAttribute(id, value);
- return (SKIP_BODY);
- }
-
- // Deal with multiple header values
- ArrayList values = new ArrayList();
- Enumeration items =
- ((HttpServletRequest) pageContext.getRequest()).getHeaders(name);
- while (items.hasMoreElements())
- values.add(items.nextElement());
- if ((values.size() == 0) && (this.value != null))
+ pageContext.setAttribute(id, value);
+ return (SKIP_BODY);
+ }
+
+ // Deal with multiple header values
+ ArrayList values = new ArrayList();
+ Enumeration items =
+ ((HttpServletRequest) pageContext.getRequest()).getHeaders(name);
+
+ while (items.hasMoreElements()){
+ values.add(items.nextElement());
+ }
+
+ if ((values.size() == 0) && (this.value != null)){
values.add(this.value);
- String headers[] = new String[values.size()];
- if (headers.length == 0) {
- JspException e = new JspException
- (messages.getMessage("header.get", name));
+ }
+
+ String headers[] = new String[values.size()];
+ if (headers.length == 0) {
+ JspException e =
+ new JspException(messages.getMessage("header.get", name));
RequestUtils.saveException(pageContext, e);
throw e;
}
- pageContext.setAttribute(id, (String[]) values.toArray(headers));
+
+ pageContext.setAttribute(id, (String[]) values.toArray(headers));
return (SKIP_BODY);
}
-
/**
* Release all allocated resources.
*/
@@ -210,6 +208,5 @@
value = null;
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org