I's using a bean to validate a form.  Based on how the form data is
validated or not validated by the bean the JSP forwards to one of 2 pages.
Both of these pages use the bean's properties to display information
submitted.  Both these pages get and error when intiating the bean.

Here's the code on the first page to initiate the bean and check the form,
this works fine:

<jsp:useBean id="formHandler" class="foo.FormBean" scope="request">
<jsp:setProperty name="formHandler" property="*"/>
</jsp:useBean>

<% if (formHandler.validate()) {
%>
        <jsp:forward page="success.jsp" />
<%
   }  else {
%>
        <jsp:forward page="retry.jsp" />
<%
   }
%>



Here's the code on the second page ( success.jsp and retry.jsp ) which
creates the error:

<jsp:useBean id="formHandler" class="foo.FormBean" scope="request"/>


Error:

java.lang.ClassCastException: foo.FormBean
        at _jsps._java._AForms._success_jsp._jspService(_success_jsp.java:66)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:826)
        at
com.netscape.server.http.servlet.NSServletRunner.Service(NSServletRunner.jav
a:502)
        at
com.netscape.server.http.servlet.NSServletSession.internalRedirect(Native
Method)
        at
com.netscape.server.http.servlet.NSRequestDispatcher.forward(NSRequestDispat
cher.java:67)
        at
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:355)
        at _jsps._java._AForms._process_jsp._jspService(_process_jsp.java:119)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:826)
        at
com.netscape.server.http.servlet.NSServletRunner.Service(NSServletRunner.jav
a:502)

These pages only returns data from the bean so I'm not sure why an error
like this would occur since the bean ran on the page before.  If I check the
_success_jsp.java:66 code it's the same as the code form the first page
where the bean executed with out a problem.  Any help woud be great.

Thanks,
Nate Kresse
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
Senior Developer

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to