This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Assigning bean value to string variable in Struts

 
Gemini Moses
Ranch Hand
Posts: 245
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am passing a string value city from action class to a jsp.
In my jsp I need to assign this valut to a string variable
I tried it this way , and it fails.
<% String city=null; %>
<% city = <bean:write name="city"/>; %>
In my action class I have
request.setArrtibute("city",ppp);
Can someone please suggest me how should I be doing it?
Thanks,
 
Junilu Lacar
Bartender
Pie
Posts: 6529
21
Java Linux Mac Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try
<% city = request.getAttribute("city"); %>
Junilu
 
gautam shah
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Junilu Lacar:
try
<% city = request.getAttribute("city"); %>
Junilu

or try

<% city = (String)request.getAttribute("city"); %>
 
Gemini Moses
Ranch Hand
Posts: 245
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Junilu and Gautam!!
It is working fine!!!
This site is great....
I get answers of all my doubts....
Casting was required.
Thanks a lot.
 
gilles vandaele
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it doesn't work for me:
I've an 'org.apache.jasper.compiler.ParseException: /zwhateverz.jsp(184,103) Attribute xwhateverx has no value' exception (Tomcat 4.0.3 internal server error)
in the perform method of my Actionservlet:
request.setAttribute("fieldList", anArrayList);
in my jsp:
<%= (ArrayList)request.getAttribute("fieldList")%>
Actualy I need to retrieve the ArrayList to be the collection of a logic:iterate Struts tag; is it right?)
Help!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic