• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Action - getAttribute

 
Kris Reid
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you get a Attribute from an action?
If so how?

<%
request.setAttribute("thing", "5555");
%>

<jsp:getProperty name="thing" ???
 
shiva viswanathan
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by action do you mean servlet class
Can you explain more clearly
 
Kris Reid
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm referring to stand actions in JSP

Can you get an attribute?

with a scriplet you may use
<%
request.getAttribute("thing");
%>
Can you do it with standard actions?
If so what would the code be

<jsp:getAttribute name="thing" ???
 
Saulius Sinkunas
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According JSP-2.0 spec JSP.5.3 section, <jsp:getProperty> can use bean, which is in PageScope, for example, it was defined with <jsp:useBean>. So if use want to use standart actions, you must at first declare that attribute in page scope (<jsp:useBean> and then use <jsp:getProperty>.

But better is to use EL: ${requestScope.thing}
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kris Reid:
Can you get a Attribute from an action?
If so how?


My simple answer would be NO. . As Saulius explained, Using <jsp:getProperty> tag you can get property values of Java Beans that have been created before using <jsp:UseBean> tag only.
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Commonly used legal JSP actions:
1. <jsp:useBean>
2. <jsp:getProperty>
3. <jsp:setProperty>
4. <jsp:forward>
5. <jsp:include>
6. <jsp:plugin>
<jsp:params> is considered to be a special tag(to be used with <jsp:include> and <jsp:forard> tags to pass parameters)

Note: I have edited my post. I am yet to read about the tag <jsp:attribute>
[ May 19, 2005: Message edited by: Vishwa Kumba ]
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kris Reid:
I'm referring to stand actions in JSP

Can you get an attribute?

with a scriplet you may use
<%
request.getAttribute("thing");
%>
Can you do it with standard actions?
If so what would the code be

<jsp:getAttribute name="thing" ???


Kris,
Looks like there is no <jsp:getAttribute> tag for this!. So I am afraid the answer is still NO.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic