Re: Using Standard Tag Library to Display a Request Attribute

2003-02-09 Thread Shawn Bayern
On Sun, 9 Feb 2003, Shadow X wrote:

 What if I needed to use a key to lookup the parameter value?
 
 For instance:
 
 c:out value=${requestScope['org.apache.struts.Globals.LOCALE_KEY']}
 /
 
 org.apache.struts.Globals.LOCALE_KEY actually maps to
 org.apache.struts.action.LOCALE

If I'm understanding the request right, the following would work:

 ${requestScope[requestScope['org.apache.struts.Globals.LOCALE_KEY']]}

-- 
Shawn Bayern
JSTL in Action   http://www.manning.com/bayern


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Using Standard Tag Library to Display a Request Attribute

2003-02-09 Thread Shawn Bayern
No, but that's only because 'org.apache.struts.Globals' isn't a scoped
variable; the expression language can't be used to retrieve static fields
in a class.  The expression language is designed to access only certain
kinds of data.

-- 
Shawn Bayern
JSTL in Action   http://www.manning.com/bayern

On Sun, 9 Feb 2003, Shadow X wrote:

 I tried the nesting of [] but it doesn't seem to work.
 
 Perhaps I should make my situation clearer.  I've saved the locale
 object under the key org.apache.struts.Globals.LOCALE_KEY  (with
 setLocale(request,locale) in struts)
 
 Now in my jsp I want to retrieve the locale. I tried:
 
 c:set scope=page var=lo
 value=${sessionScope[sessionScope['org.apache.struts.Globals.LOCALE_KEY
 ']]}/
 Language = c:out value=${pageScope.lo.language} /
 
 But all I get is an empty string. The following works, but requires an
 extra variable:
 
 %@ page import=org.apache.struts.Globals %
 c_rt:set var=locale_key
 value=%=org.apache.struts.Globals.LOCALE_KEY%/
 c:set scope=page var=locale value=${sessionScope[locale_key]}/
 Language= c:out value=${pageScope.locale.language}/
 
 I was wondering if there was a way to do it without using a runtime
 expression and an extra variable.
 
 Thanx for your time.
 
  ~Shadow
 
  On Sun, 9 Feb 2003, Shadow X wrote:
  
   What if I needed to use a key to lookup the parameter value?
   
   For instance:
   
   c:out 
  value=${requestScope['org.apache.struts.Globals.LOCALE_KEY']}
   /
   
   org.apache.struts.Globals.LOCALE_KEY actually maps to 
   org.apache.struts.action.LOCALE
  
  If I'm understanding the request right, the following would work:
  
   ${requestScope[requestScope['org.apache.struts.Globals.LOCALE_KEY']]}
  
  -- 
  Shawn Bayern
  JSTL in Action   http://www.manning.com/bayern
  
 
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Using Standard Tag Library to Display a Request Attribute

2003-02-06 Thread Shawn Bayern
On Thu, 6 Feb 2003, Renick, Garrel wrote:

 c:out value=${requestScope.javax.servlet.error.message} /
 
 Is there a trick to displaying request attributes with JSTL? Is the
 expression language interpreting the periods in the attribute name?

Yes, it is.  To avoid this, you can use expressions like the following:

  c:out value=${requestScope['javax.servlet.error.message']} /

The [] syntax works wherever . works, but it lets you avoid problems when
the property name itself contains a period.

-- 
Shawn Bayern
JSTL in Action   http://www.manning.com/bayern


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]