• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

INCLUDES.DBconnection error

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

My file name is course_list1_model2.jsp

my code as follows. But please find the error as soon as possible. I got this error 57 error in my project. All error shows this line only

"The value for the useBean class attribute INCLUDES.DBConnection is invalid."

<%@ page import="INCLUDES.DBConnection"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB" property="*"/>
<jsp:useBean id="DB1" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB1" property="*"/>
<%
String sort_by="";
String user_name=(String)session.getAttribute("user_name");
if(user_name==null)
{
response.sendRedirect("course_list_index2.jsp");
}
if(request.getParameter("sort_by")!=null)
{
sort_by=request.getParameter("sort_by");
}
if(sort_by.equals("category"))
{
sort_by="course_category,course_name";
}
else
{
sort_by="course_name";
}
String statement="select * from x_masterListOfCourses s,x_masterListOfCategory cat where s.course_category_id=cat.course_category_id order by " + sort_by;
ResultSet objRs=null;
ResultSet oRsTraineeStatus=null;
try
{
DB.setStatement(statement);
objRs=(ResultSet)DB.result();

}
catch(Exception e)
{
%>error occured : <%=e%><%
}
%>
<html>
<head>
<title>e-Learning</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function fnMenuBg1(elementId)
{
document.getElementById(elementId).style.backgroundColor="#dfdfdf";
}
function fnMenuBg2(elementId)
{
document.getElementById(elementId).style.backgroundColor="";
}

</script>
</head>
<body topmargin="0">
<table width="100%" height="200" background="bg_top.jpg">
<tr>
<td align="right" valign="top">
<table border="0" align="right" cellpadding="0" cellspacing="0" >
<tr align="center">
<td height="15" id=home><a href="course_list_index2.jsp" class="menuLink" onMouseOver="fnMenuBg1('home')" onMouseOut="fnMenuBg2('home')">
   Home   </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" id=profile><a href="view_profile.jsp" class="menuLink" onMouseOver="fnMenuBg1('profile')" onMouseOut="fnMenuBg2('profile')">  View
Profile  </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" id=password><a href="change_password.jsp" class="menuLink" onMouseOver="fnMenuBg1('password')" onMouseOut="fnMenuBg2('password')">  Change
Password  </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td width="1" height="15" id=logout><a href="logout.jsp" class="menuLink" onMouseOver="fnMenuBg1('logout')" onMouseOut="fnMenuBg2('logout')">  Logout  </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" align="right" class="login" >  Login by:<%=user_name%>
</td>
</tr>
</table>
</td>
</tr></table>
<!--start of result display-->
<table width="100%" >
<tr>
<td>
<%if(request.getParameter("result")!=null)
{
%>
<marquee loop="1" behavior="alternate"><strong>
<font color="#FF0000" size="2" face="Arial, Helvetica, sans-serif">
<%=request.getParameter("result")%></font></strong></marquee>
<% }%>
</td>
</tr>
</table>
<!--end of result display-->
<table width="100%" height="858" >
<tr>
<td align="center" valign="top"> <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolorlight="#FFFFFF">
<tr bgcolor="#FF9900">
<td width="4%" height="25"> <div align="center">
<font color="#FFFFFF" face="Arial, Helvetica, sans-serif"><strong>
<font size="2">S.No</font></strong></font></div></td>
<td height="25"> <div align="center"><font color="#FFFFFF" face="Arial, Helvetica, sans-serif"><strong><font size="2">C.
Code</font></strong></font></div></td>
<td width="34%" height="25"> <div align="center">
<font color="#FFFFFF"><a href="course_list1_model2.jsp?sort_by=course" title="Click here to sort by course name">
<font face="Arial, Helvetica, sans-serif"><strong><font size="2" color="#FFFFFF">Course
Name</font></strong></font></a></font></div></td>
<td width="21%" height="25"> <div align="center">
<font color="#FFFFFF"><a href="course_list1_model2.jsp?sort_by=category" title="Click here to sort by course name"><font face="Arial, Helvetica, sans-serif"><strong><font size="2" color="#FFFFFF">Course
Category</font></strong></font></a></font></div></td>
<td width="24%" height="25"> <div align="center">
<font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong>Your
Status</strong></font></div></td>
<td width="10%" height="25"> <div align="center">
<font color="#FFFFFF" face="Arial, Helvetica, sans-serif"><strong> </strong></font></div></td>
</tr>
<%
try
{
int i=1;
while(objRs.next())
{
%>
<%
int course_id=objRs.getInt("course_id");
int no_of_attempts=0;
int is_successfully_completed=0;
String date_of_registration_str=null;
String course_completed_date_str=null;
java.util.Date date_of_registration=null;
java.util.Date course_completed_date=null;
int is_registered=0;
String back_color="";
try
{
String statement1="select * from x_master_trainee_detail_online where course_id=" + course_id + " and user_name='" + session.getAttribute("user_name") + "'";
DB1.setStatement(statement1);
oRsTraineeStatus=DB1.result();
if(oRsTraineeStatus.next())
{
is_registered=oRsTraineeStatus.getInt("is_registered");
date_of_registration=oRsTraineeStatus.getDate("doe");
date_of_registration_str=date_of_registration.getDate() + "-" + (date_of_registration.getMonth()+1) + "-" + (date_of_registration.getYear()+1900);
is_successfully_completed=oRsTraineeStatus.getInt("is_successfully_completed");
course_completed_date=oRsTraineeStatus.getDate("course_completed_date");
course_completed_date_str=course_completed_date.getDate() + "-" + (course_completed_date.getMonth()+1) + "-" + (course_completed_date.getYear()+1900);
}
}
catch(Exception ex)
{

}
if(is_successfully_completed==1)
{
back_color="bgcolor=#FFFFCC";
}
else
{
if(is_registered==1)
{
back_color="bgcolor=#f0f0ff";
}
else
{
back_color="";
}
}
%>
<tr <%=back_color%>>
<td height="30"> <div align="center"><font color="#666666" size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=i%></font></div></td>
<td height="30" ><div align="center"><font color="#666666" size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=course_id%></font>
</div></td>
<td height="30" title="<%=objRs.getString("course_description")%>" ><font color="#666666" size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=objRs.getString("course_name")%></font></td>
<td height="30"> <div align="left"><font color="#666666" size="2" face="Verdana, Arial, Helvetica, sans-serif" ><%=objRs.getString("course_category")%></font></div></td>
<td height="30"> <font color="#666666">
<%
if(is_successfully_completed > 0)
{%>
<font size="1" face="Arial, Helvetica, sans-serif">Successfully completed
on <%=course_completed_date_str%></font></font> <font color="#666666">
<%
}
else
{
if(is_registered==1)
{
%>
<font size="1" face="Arial, Helvetica, sans-serif"> Enrolled on <%=date_of_registration_str%><br>
(not yet completed)</font></font> <font color="#666666">
<% }
else
{%>
<font size="1" face="Arial, Helvetica, sans-serif">Not yet enrolled</font></font><font color="#666666" size="2" face="Arial, Helvetica, sans-serif"><strong>
</strong></font> <font color="#666666">
<% }
}%>
</font></td>
<td height="30"> <div align="center"><a href="course_step.jsp?course_id=<%=course_id%>">
<font color="#FF0000" size="2" face="Arial, Helvetica, sans-serif"><strong>
select<font color=#336699 face="Times New Roman">► </font></strong></font></a></div></td>
</tr>
<%
i=i+1;
}
}
catch(Exception e)
{
%>
Error ocuured in while : <%=e%>
<%
}
%>
</table>
<!--old----------------------------------------------->
<font color="#000099" size="2" face="Arial, Helvetica, sans-serif"><br>
<br>
</font> </td>
</tr>
</table>
<br>
</div>
</body>
</html>


WHILE RUN THIS I GOT THE FOLLOWING ERROR

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /course_list1_model2.jsp(5,0) The value for the useBean class attribute INCLUDES.DBConnection is invalid.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

org.apache.jasper.JasperException: /course_list1_model2.jsp(5,0) The value for the useBean class attribute INCLUDES.DBConnection is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1174)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Generator.generate(Generator.java:3305)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

can anybody solve this
 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, Welcome to Java Ranch!

You really need to read this: UseCodeTags, and this: EaseUp

Do you really want to do Java programming in the JSP page? This is really not done anymore. There should be no Java code in there at all. Instead, you should place all the application logic in (or behind) the Servlet and use the JSP as a view device only (to gather user input and display results). Trying to write application code in a JSP page is going to complicate your life. This article will help: http://www.javaranch.com/journal/200603/Journal200603.jsp#a5

Now, as to your problem, the error says: "The value for the useBean class attribute INCLUDES.DBConnection is invalid."

Do you really have a class named DBConnection in the INCLUDES package? That does not sound like a reasonable package name. Perhaps you can provide the directory structure of your application, so we can see where everything is located? Make sure you UseCodeTags, then just do it like this:

Edit: And please go back and Edit your original post to add in the code tags
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, please see IsolateTheProblem: Try to find the minimal number of lines that still show your problem. If you can reduce the code you need to show to 10 lines, many more people will be willing to take a look at it. In this example, all or most of the HTML you've posted isn't related, and serves only to obfuscate the real issue.

And welcome to JavaRanch!
 
You save more money with a clothesline than dozens of light bulb purchases. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic