This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class cast exception in use bean

 
dinakarkalaga kalaga
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64606
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I'd highly recommend LoginCheck if you want to be one of the cool kids.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic