wood burning stoves 2.0*
The moose likes Struts and the fly likes struts question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts question" Watch "struts question" New topic
Author

struts question

Vardhan Muthineni
Greenhorn

Joined: May 18, 2006
Posts: 8
HI,
This is vardhan,
I have one problem with struts.
IN jsp iam entering one number and iam taking that number in action class and iam inserting integers from 1 to upto that given number in an ARRAYLIST.After that iam placing that arraylist object in session.NOw I want to get that arraylist object in the seccess jps page and i want to print that arraylist.
but in success.jsp page iam getting class cast exception.
here iam provindin the coed.Can any one give the suggession:
ACTION CLASS execute method:
{
InsertForm insert=(InsertForm)form;
String number=insert.getNumber();
int n=Integer.parseInt(number);
ArrayList al=new ArrayList();
for(int i=0;i<n;i++)
al.add(new Integer(i));
System.out.println(al);
String target="success";
if(number==null)
{ target="failure";

}
else
{ HttpSession session = request.getSession(true);
session.setAttribute("al","al");
}

return (mapping.findForward(target));

}
SUCCESS.JPS:<%@page import="java.util.ArrayList" session="true"%>
<html>
<head><title></title></head>
<body>
<p><b>SUCESS FULL INSERTION IN THE ARRAYLIST</b></P>
</body>
</html>
<%/////here in this line it is giving the error////
ArrayList a=(ArrayList)session.getAttribute("al");
out.println(a);
%>

STRUTS-CONFIG.XML:
<action path="/insert" type="InsertAction" name="InsertForm">
<forward name="success" path="/success.jsp"/>
<forward name="failure" path="/index.jsp"/>
</action>
vidya sagar
Ranch Hand

Joined: Mar 02, 2005
Posts: 580
hi vardhan

In your Action class

Change this line
session.setAttribute("al","al");
to
session.setAttribute("al",al);

Hope now program runs
Vardhan Muthineni
Greenhorn

Joined: May 18, 2006
Posts: 8
HI sagar
thank u yar
thanks alot.
I got it.
Keep in touch,have a nice day
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts question
 
Similar Threads
Change color of clicked link - tiles
Problem while creating Struts application
struts question
Validation not working - any ideas
html:iterate or html:multibox problem