This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts question

 
Vardhan Muthineni
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic