jQuery in Action, 2nd edition*
The moose likes JSP and the fly likes class cast exception in use bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "class cast exception in use bean" Watch "class cast exception in use bean" New topic
Author

class cast exception in use bean

dinakarkalaga kalaga
Greenhorn

Joined: Jul 21, 2005
Posts: 2
hi
i am getting class cast exception for code given below
one in a while,please let me know to avoid it.
thanks in advance
dinakar

<%@ page import="school.*" %>
<jsp:useBean id="check" scope="session" class="school.login_check" />
<jsp:setProperty name="check" property="username" param="username" />
<jsp:setProperty name="check" property="password" param="password" />

<% String username=request.getParameter("username");%>
<% String rol=request.getParameter("role");%>
<%
out.println(rol);
if(rol.equals("teacher")){
check.staffregister();
//login_check a =new login_check();
if(check.iscorrect()){


session.setAttribute("username", username); %>
<jsp:forward page="teacher_main.jsp" />

<%}
else{
%>

<jsp:forward page="teacher_login.jsp" />
<% }
}
else
{
check.registered();
out.println(check.isAuthorised());
if(check.isAuthorised()){
session.setAttribute("username", username); %>
<jsp:forward page="student_main.jsp" />
<%
}
else{
%>

<jsp:forward page="stud_login.jsp" />

<%
}
} %>


result is

Error 500--Internal Server Error
java.lang.ClassCastException
at jsp_servlet.__ch._jspService(__ch.java:153)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1053)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6310)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3622)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2569)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The most likely explanation for this error is that at some point prior to displaying this page, another process put an object in the session under the name "check" that is not of type "school.login_check".

P.S. It's generally accepted practice that class names start with a capital letter. If the name of the class is Login_check, then the misspelling of the class name is the problem. Otherwise, I'd suggest you change the name of the login_check class to Login_check.


Merrill
Consultant, Sima Solutions
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61448
    
  67

Actually, I'd highly recommend LoginCheck if you want to be one of the cool kids.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: class cast exception in use bean