my dog learned polymorphism*
The moose likes Struts and the fly likes Assigning bean value to string variable in Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Assigning bean value to string variable in Struts" Watch "Assigning bean value to string variable in Struts" New topic
Author

Assigning bean value to string variable in Struts

Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
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

Joined: Feb 26, 2001
Posts: 4447
    
    5

try
<% city = request.getAttribute("city"); %>
Junilu
gautam shah
Ranch Hand

Joined: Oct 29, 2000
Posts: 72
Originally posted by Junilu Lacar:
try
<% city = request.getAttribute("city"); %>
Junilu

or try

<% city = (String)request.getAttribute("city"); %>
Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
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

Joined: Jul 10, 2002
Posts: 3
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!


Gilles
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assigning bean value to string variable in Struts
 
Similar Threads
html - el tags
jsp with beans not handling
how to specify composite data in s struts FORM
Bean or Servlet
JSP