Viruthagiri Thirumalvalavan

Greenhorn
+ Follow
since Mar 21, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Viruthagiri Thirumalvalavan

My project is e learning project. I've a "choose the correct answer" module. When the click the "begin test" button it should fetch the questions and options from database and display it. Instead of that my page displays "java.lang.NullPointerException".
I've assigned unique values for each error. So the exact error it display as

"error occured 56 : java.lang.NullPointerException"

I have found the area of the error. but i couldn't solve it.
My codings are as follows



Please help me to solve this error. i'll be very thankful to you. If you need extra code tell me which part you want to solve this error. I'll post here. thanks to everyone. A little piece of help also appriciated
10 years ago
JSP
Guys i got file enroll.jsp while executing that i got java.lang.NullPointerException. So please solve this,

my code as follows

Code:
//enroll.jsp//
<%@ 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="*"/>
<%
int course_id=Integer.parseInt(request.getParameter("course_id"));
int no_of_papers=0;
String statement="";
try
{
statement="select no_of_papers from x_masterListOfCourses where course_id=" + course_id;
DB1.setStatement(statement);
ResultSet objRs=(ResultSet)DB1.result();
if(objRs.next())
{
no_of_papers=objRs.getInt("no_of_papers");
}
}
catch(Exception e)
{
out.print("error occured while executing the query:" + e);
}
try
{
String user_name=(String)session.getAttribute("user_name");
java.util.Date now=new java.util.Date();
java.sql.Date date=new java.sql.Date(now.getYear(),now.getMonth(),now.getDate());
String trainee_id="OL_" + course_id + "_" + user_name;
statement="select * from x_master_trainee_detail_online";
DB.setStatement(statement);
ResultSet objRsInsert=(ResultSet)DB.resultUpdate();
objRsInsert.next();
objRsInsert.updateString("trainee_id",trainee_id);
session.setAttribute("trainee_id",trainee_id);
objRsInsert.updateString("user_name",user_name);
objRsInsert.updateInt("is_registered",1);
objRsInsert.updateInt("is_paper1_tutorial_viewed",0);
objRsInsert.updateInt("is_paper2_tutorial_viewed",0);
objRsInsert.updateInt("is_paper3_tutorial_viewed",0);
objRsInsert.updateInt("is_paper4_tutorial_viewed",0);
objRsInsert.updateInt("is_paper5_tutorial_viewed",0);
objRsInsert.updateInt("is_attended_exam",0);
objRsInsert.updateInt("course_id",course_id);
objRsInsert.updateInt("paper1_no_of_attempts",0);
objRsInsert.updateInt("paper2_no_of_attempts",0);
objRsInsert.updateInt("paper3_no_of_attempts",0);
objRsInsert.updateInt("paper4_no_of_attempts",0);
objRsInsert.updateInt("paper5_no_of_attempts",0);
objRsInsert.updateInt("is_paper1_completed",0);
objRsInsert.updateInt("is_paper2_completed",0);
objRsInsert.updateInt("is_paper3_completed",0);
objRsInsert.updateInt("is_paper4_completed",0);
objRsInsert.updateInt("is_paper5_completed",0);
objRsInsert.updateInt("paper1_marks",0);
objRsInsert.updateInt("paper2_marks",0);
objRsInsert.updateInt("paper3_marks",0);
objRsInsert.updateInt("paper4_marks",0);
objRsInsert.updateInt("paper5_marks",0);
objRsInsert.updateDate("doe",date);
objRsInsert.updateInt("no_of_papers",no_of_papers);
objRsInsert.insertRow();
response.sendRedirect("course_step.jsp?result=Enrolled successfully.&course_id=" + course_id);

}
catch(Exception e)
{
out.print("error occured while inserting: " + e);
}
%>

sql table is as follows

Code:
-- phpMyAdmin SQL Dump
-- version 2.6.0-rc1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Mar 24, 2010 at 02:30 AM
-- Server version: 4.0.20
-- PHP Version: 5.0.1
--
-- Database: `elearning_datasource`
--

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

--
-- Table structure for table `x_master_trainee_detail_online`
--

CREATE TABLE `x_master_trainee_detail_online` (
`trainee_id` varchar(25) NOT NULL default '',
`is_registered` int(10) NOT NULL default '0',
`is_attended_exam` int(10) NOT NULL default '0',
`is_successfully_completed` int(10) NOT NULL default '0',
`course_completed_date` date NOT NULL default '0000-00-00',
`total_marks` int(10) NOT NULL default '0',
`doe` date NOT NULL default '0000-00-00',
`user_name` varchar(25) NOT NULL default '',
`course_id` int(10) NOT NULL default '0',
`paper1_no_of_attempts` int(10) NOT NULL default '0',
`paper2_no_of_attempts` int(10) NOT NULL default '0',
`paper3_no_of_attempts` int(10) NOT NULL default '0',
`paper4_no_of_attempts` int(10) NOT NULL default '0',
`paper5_no_of_attempts` int(10) NOT NULL default '0',
`paper1_marks` int(10) NOT NULL default '0',
`paper2_marks` int(10) NOT NULL default '0',
`paper3_marks` int(10) NOT NULL default '0',
`paper4_marks` int(10) NOT NULL default '0',
`paper5_marks` int(10) NOT NULL default '0',
`paper1_completed_date` date NOT NULL default '0000-00-00',
`paper2_completed_date` date NOT NULL default '0000-00-00',
`paper3_completed_date` date NOT NULL default '0000-00-00',
`paper4_completed_date` date NOT NULL default '0000-00-00',
`paper5_completed_date` date NOT NULL default '0000-00-00',
`paper_id1` int(10) NOT NULL default '0',
`paper_id2` int(10) NOT NULL default '0',
`paper_id3` int(10) NOT NULL default '0',
`paper_id4` int(10) NOT NULL default '0',
`paper_id5` int(10) NOT NULL default '0',
`is_paper1_completed` int(10) NOT NULL default '0',
`is_paper2_completed` int(10) NOT NULL default '0',
`is_paper3_completed` int(10) NOT NULL default '0',
`is_paper4_completed` int(10) NOT NULL default '0',
`is_paper5_completed` int(10) NOT NULL default '0',
`paper1_appeared_on` date NOT NULL default '0000-00-00',
`paper2_appeared_on` date NOT NULL default '0000-00-00',
`paper3_appeared_on` date NOT NULL default '0000-00-00',
`paper4_appeared_on` date NOT NULL default '0000-00-00',
`paper5_appeared_on` date NOT NULL default '0000-00-00',
`is_paper1_tutorial_viewed` int(10) NOT NULL default '0',
`is_paper2_tutorial_viewed` int(10) NOT NULL default '0',
`is_paper3_tutorial_viewed` int(10) NOT NULL default '0',
`is_paper4_tutorial_viewed` int(10) NOT NULL default '0',
`is_paper5_tutorial_viewed` int(10) NOT NULL default '0',
`no_of_papers` int(10) NOT NULL default '0',
PRIMARY KEY (`trainee_id`)
) TYPE=MyISAM;

--
-- Dumping data for table `x_master_trainee_detail_online`
--
Can you tell me what is that error. Any kind of help will be appreciated. thanks
10 years ago
JSP

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
10 years ago
JSP