This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have David & Dawn Griffiths on-line!
See this thread for details.
Win a copy of Head First Android this week in the Android forum!

fiza jay

Greenhorn
+ Follow
since Apr 09, 2003
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 fiza jay

what it mean by record added is dat: on my web page rite, there will be an adding form so that i can insert a new record, but when i click on the submit button, my web page will show it has been added.
But inside my xml, doesnt have the record which i have added...
18 years ago
now there's no error as in the NullPointerException but now it just wont save the record that i have added. What i mean is that once i have added a record, it says record added but when i view all the records, there isnt any record added. Same goes for the editing and deleting. It just didnt save inside my xml database.
Why is that so???
Thanx in advance
18 years ago
so how do i debug this error??? Im not so gd in Java and JSP.. Anybody can at least give a hint on how i debug this error... Coz i have no clue in this.. I do not also know how m i suppose to do with the catch exception..
Thanx..
18 years ago
This is my jsp code:
%@ page import="java.io.File,
org.dom4j.Document,
org.dom4j.Element,
org.dom4j.io.SAXReader" %>
lt%
// get the parameters:
int id = 0;
try
{
id = Integer.parseInt( request.getParameter("id") );
} catch ( NumberFormatException ne ) {}
String name = request.getParameter("name");
String school = request.getParameter("school");
String centre = request.getParameter("centre");
String staffcategory = request.getParameter("staffcategory");
String staffinvolvement = request.getParameter("staffinvolvement");
String areasofresearch = request.getParameter("areasofresearch");
String qualifications = request.getParameter("qualifications");
String citizenship = request.getParameter("citizenship");
String staffparticulars = request.getParameter("staffparticulars");
// parse the document:
SAXReader reader = new SAXReader();
String path = application.getRealPath("/ViewStaff_list.xml");
Document doc = reader.read( new File(path) );
if ( id == 0 )
{
// if we have a new project then we generate the id by
// adding 1 to the ID of the last node:
java.util.List list = doc.selectNodes( "//staff-list/staff" );
org.dom4j.Node lastStaff = (org.dom4j.Node) list.get( list.size()-1 );
id = Integer.parseInt( lastStaff.valueOf("@id") ) + 1;
// create the new element
Element newStaff = doc.getRootElement().addElement( "staff" )
.addAttribute( "id", Integer.toString(id) );
newStaff.addElement("name").addText(name);
newStaff.addElement("school").addText(school);
newStaff.addElement("centre").addText(centre);
newStaff.addElement("staffcategory").addText(staffcategory);
newStaff.addElement("staffinvolvement").addText(staffinvolvement);
newStaff.addElement("areasofresearch").addText(areasofresearch);
newStaff.addElement("qualifications").addText(qualifications);
newStaff.addElement("citizenship").addText(citizenship);
newStaff.addElement("staffparticulars").addText(staffparticulars);

}
else
{
// we locate the project that we are going to modify
Element staff = (Element) doc.selectSingleNode( "//staff-list/staff[@id=" + id + "]" );
// and then we modify the values
staff.selectSingleNode( "name" ).setText(name);
staff.selectSingleNode( "school" ).setText(school);
staff.selectSingleNode( "centre" ).setText(centre);
staff.selectSingleNode( "staffcategory" ).setText(staffcategory);
staff.selectSingleNode( "staffinvolvement" ).setText(staffinvolvement);
staff.selectSingleNode( "areasofresearch" ).setText(areasofresearch);
staff.selectSingleNode( "qualifications" ).setText(qualifications);
staff.selectSingleNode( "citizenship" ).setText(citizenship);
staff.selectSingleNode( "staffparticulars" ).setText(staffparticulars);
}
// write the file:
java.io.FileWriter output = new java.io.FileWriter( path );
doc.write( output );
output.close();
%>
This my jsp_java code:
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.apache.jasper.runtime.*;
import java.io.File;
import java.util.*;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
public class SaveStaff_jsp extends HttpJspBase {

private static java.util.Vector _jspx_includes;
public java.util.List getIncludes() {
return _jspx_includes;
}
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
JspFactory _jspxFactory = null;
javax.servlet.jsp.PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;

try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html;charset=ISO-8859-1");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n\r\n");
// get the parameters:
int id = 0;
try
{
id = Integer.parseInt( request.getParameter("id") );
} catch ( NumberFormatException ne ) {}
String name = request.getParameter("name");
session.setAttribute("staff", name);
String school = request.getParameter("school");
session.setAttribute("staff", school);
String centre = request.getParameter("centre");
session.setAttribute("staff", centre);
String staffcategory = request.getParameter("staffcategory");
session.setAttribute("staff", staffcategory);
String staffinvolvement = request.getParameter("staffinvolvement");
session.setAttribute("staff", staffinvolvement);
String areasofresearch = request.getParameter("areasofresearch");
session.setAttribute("staff", areasofresearch);
String qualifications = request.getParameter("qualifications");
session.setAttribute("staff", qualifications);
String citizenship = request.getParameter("citizenship");
session.setAttribute("staff", citizenship);
String staffparticulars = request.getParameter("staffparticulars");
session.setAttribute("staff", staffparticulars);
// parse the document:
SAXReader reader = new SAXReader();
String path = application.getRealPath("/ViewStaff_list.xml");
Document doc = reader.read( new File(path) );

if ( id == 0 )

{
// if we have a new project then we generate the id by
// adding 1 to the ID of the last node:
java.util.List list = doc.selectNodes( "//staff-list/staff" );
org.dom4j.Node lastStaff = (org.dom4j.Node) list.get( list.size()-1 );
id = Integer.parseInt( lastStaff.valueOf("@id") ) + 1;
// create the new element
Element newStaff = doc.getRootElement().addElement( "staff" )
.addAttribute( "id", Integer.toString(id) );
if(name != null) {
newStaff.addElement("name").addText(name);
}else {
newStaff.addElement("name").addText("");
}
if(school != null) {
newStaff.addElement("school").addText(school);
}else {
newStaff.addElement("school").addText("");
}
if(centre != null) {
newStaff.addElement("centre").addText(centre);
}else {
newStaff.addElement("centre").addText("");
}
if(staffcategory != null) {
newStaff.addElement("staffcategory").addText(staffcategory);
}else {
newStaff.addElement("staffcategory").addText("");
}
if(staffinvolvement != null) {
newStaff.addElement("staffinvolvement").addText(staffinvolvement);
}else {
newStaff.addElement("staffinvolvement").addText("");
}
if(areasofresearch != null) {
newStaff.addElement("areasofresearch").addText(areasofresearch);
}else {
newStaff.addElement("areasofresearch").addText("");
}
if(qualifications != null) {
newStaff.addElement("qualifications").addText(qualifications);
}else {
newStaff.addElement("qualifications").addText("");
}
if(citizenship != null) {
newStaff.addElement("citizenship").addText(citizenship);
}else {
newStaff.addElement("citizenship").addText("");
}
if(staffparticulars != null) {
newStaff.addElement("staffparticulars").addText(staffparticulars);
}else {
newStaff.addElement("staffparticulars").addText("");
}

}

else
{
// we locate the project that we are going to modify
Element staff = (Element) doc.selectSingleNode( "//staff-list/staff[@id=" + id + "]" );
// and then we modify the values
staff.selectSingleNode( "name" ).setText(name);
staff.selectSingleNode( "school" ).setText(school);
staff.selectSingleNode( "centre" ).setText(centre);
staff.selectSingleNode( "staffcategory" ).setText(staffcategory);
staff.selectSingleNode( "staffinvolvement" ).setText(staffinvolvement);
staff.selectSingleNode( "areasofresearch" ).setText(areasofresearch);
staff.selectSingleNode( "qualifications" ).setText(qualifications);
staff.selectSingleNode( "citizenship" ).setText(citizenship);
staff.selectSingleNode( "staffparticulars" ).setText(staffparticulars);
}
// write the file:
java.io.FileWriter outWriter = new java.io.FileWriter( "ViewStaff_list.jsp" );
doc.write( outWriter );
outWriter.close();
out.write("\r\n\r\n");
out.write("<html>\r\n ");
out.write("<head>\r\n ");
out.write("<title>Success");
out.write("</title>\r\n ");
out.write("</head>\r\n ");
out.write("<body background = \"brown.jpg\">");
out.write("<font size=\"7\">\r\n");
out.write("<center>\r\n");
out.write("<br>\r\n");
out.write("<br>\r\n Staff list successfully saved.\r\n\r\n");
out.write("<br>\r\n ");
out.write("<hr>\r\n");
out.write("<br>\r\n ");
out.write("<a href=\"ViewStaff_list.jsp\">Back to Staff List");
out.write("</a>      \r\n ");
out.write("<a href=\"EditStaff.jsp\">Add another record");
out.write("</a>\r\n");
out.write("<br>\r\n");
out.write("<hr>");
out.write("</font>\r\n ");
out.write("</body>\r\n");
out.write("</html>");
} catch (Throwable t) {
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (pageContext != null) pageContext.handlePageException(t);
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
}
}
}
Thanx..
18 years ago
Im using Tomcat4.1 and j2sdk1.4.1_02 for my JSP and XML. The problem is dat when i try to save my record in the xml, it gives error=>java.lang.NullPointerException. I do not know what is the cause..
Anybody can please help me.. Thanx.
18 years ago
Now, my error came out at as dis when i try to save my add records:
java.lang.NullPointerException
at org.apache.jsp.SaveProj_jsp._jspService(SaveProj_jsp.java:102)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)
What does dis mean??
18 years ago
This is my code for SaveStaff.jsp.. Im trying to add a record using XML database and Jsp..
%@ page import="java.io.File,
org.dom4j.Document,
org.dom4j.Element,
org.dom4j.io.SAXReader" %>
lt%
// get the parameters:
int id = 0;
try
{
id = Integer.parseInt( request.getParameter("id") );
} catch ( NumberFormatException ne ) {}
String name = request.getParameter("name");
String school = request.getParameter("school");
String centre = request.getParameter("centre");
String staffcategory = request.getParameter("staffcategory");
String staffinvolvement = request.getParameter("staffinvolvement");
String areasofresearch = request.getParameter("areasofresearch");
String qualifications = request.getParameter("qualifications");
String citizenship = request.getParameter("citizenship");
String staffparticulars = request.getParameter("staffparticulars");
// parse the document:
SAXReader reader = new SAXReader();
String path = application.getRealPath("/ViewStaff_list.xml");
Document doc = reader.read( new File(path) );
if ( id == 0 )

{
// if we have a new project then we generate the id by
// adding 1 to the ID of the last node:
java.util.List list = doc.selectNodes( "//staff-list/staff" );
org.dom4j.Node lastStaff = (org.dom4j.Node) list.get( list.size()-1 );
id = Integer.parseInt( lastStaff.valueOf("@id") ) + 1;
// create the new element
Element newStaff = doc.getRootElement().addElement( "staff" )
.addAttribute( "id", Integer.toString(id) );
newStaff.addElement("name").addText(name);
newStaff.addElement("school").addText(school);
newStaff.addElement("centre").addText(centre);
newStaff.addElement("staffcategory").addText(staffcategory);
newStaff.addElement("staffinvolvement").addText(staffinvolvement);
newStaff.addElement("areasofresearch").addText(areasofresearch);
newStaff.addElement("qualifications").addText(qualifications);
newStaff.addElement("citizenship").addText(citizenship);
newStaff.addElement("staffparticulars").addText(staffparticulars);

}

else
{
// we locate the project that we are going to modify
Element staff = (Element) doc.selectSingleNode( "//staff-list/staff[@id=" + id + "]" );
// and then we modify the values
staff.selectSingleNode( "name" ).setText(name);
staff.selectSingleNode( "school" ).setText(school);
staff.selectSingleNode( "centre" ).setText(centre);
staff.selectSingleNode( "staffcategory" ).setText(staffcategory);
staff.selectSingleNode( "staffinvolvement" ).setText(staffinvolvement);
staff.selectSingleNode( "areasofresearch" ).setText(areasofresearch);
staff.selectSingleNode( "qualifications" ).setText(qualifications);
staff.selectSingleNode( "citizenship" ).setText(citizenship);
staff.selectSingleNode( "staffparticulars" ).setText(staffparticulars);
}
// write the file:
java.io.FileWriter output = new java.io.FileWriter( path );
doc.write( output );
output.close();
%>
18 years ago
Im doin jsp using Tomcat4.1 and j2sdk1.4.1_02.. When i try to add a record, it will display this error:
org.apache.jasper.JasperException: Adding text to an XML document must not be null
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Unknown Source)

root cause
java.lang.IllegalArgumentException: Adding text to an XML document must not be null
at org.dom4j.DocumentFactory.createText(DocumentFactory.java:136)
at org.dom4j.tree.AbstractElement.addText(AbstractElement.java:740)
at org.apache.jsp.SaveStaff_jsp._jspService(SaveStaff_jsp.java:83)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Unknown Source)
What does it mean ??? Is there sth wrong wif my classpath???
18 years ago
Ok, i went to Tomact\work and this is the Add_Proj.java :
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.apache.jasper.runtime.*;
import java.io.File;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
public class SaveProj_jsp extends HttpJspBase {

private static java.util.Vector _jspx_includes;
public java.util.List getIncludes() {
return _jspx_includes;
}
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
JspFactory _jspxFactory = null;
javax.servlet.jsp.PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;

try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html;charset=ISO-8859-1");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\r\n");
// get the parameters:
int id = 0;
try
{
id = Integer.parseInt( request.getParameter("id") );
} catch ( NumberFormatException ne ) {}
String projectcode = request.getParameter("projectcode");
String projecttitle = request.getParameter("projecttitle");
String school = request.getParameter("school");
String centre = request.getParameter("centre");
String projecttype = request.getParameter("projecttype");
String rnd = request.getParameter("rnd");
String expenditure = request.getParameter("expenditure");
String assetpurchased = request.getParameter("assetpurchased");
String projectstatus = request.getParameter("projectstatus");
// parse the document:
SAXReader reader = new SAXReader();
String path = application.getRealPath("/ViewProj_list.xml");
Document doc = reader.read( new File(path) );
if ( id == 0 )

{
// if we have a new project then we generate the id by
// adding 1 to the ID of the last node:
java.util.List list = doc.selectNodes( "//project-list/project" );
org.dom4j.Node lastProject = (org.dom4j.Node) list.get( list.size()-1 );
id = Integer.parseInt( lastProject.valueOf("@id") ) + 1;
// create the new element
Element newProject = doc.getRootElement().addElement( "project" )
.addAttribute( "id", Integer.toString(id) );
newProject.addElement("projectcode").addText(projectcode);
newProject.addElement("projecttitle").addText(projecttitle);
newProject.addElement("school").addText(school);
newProject.addElement("centre").addText(centre);
newProject.addElement("projecttype").addText(projecttype);
newProject.addElement("rnd").addText(rnd);
newProject.addElement("expenditure").addText(expenditure);
newProject.addElement("assetpurchased").addText(assetpurchased);
newProject.addElement("projectstatus").addText(projectstatus);
}

else
{
// we locate the project that we are going to modify
Element project = (Element) doc.selectSingleNode( "//project-list/project[@id=" + id + "]" );
// and then we modify the values
project.selectSingleNode("projectcode").setText(projectcode);
project.selectSingleNode("projecttitle").setText(projecttitle);
project.selectSingleNode("school").setText(school);
project.selectSingleNode("centre").setText(centre);
project.selectSingleNode("projecttype").setText(projecttype);
project.selectSingleNode("rnd").setText(rnd);
project.selectSingleNode("expenditure").setText(expenditure);
project.selectSingleNode("assetpurchased").setText(assetpurchased);
project.selectSingleNode("projectstatus").setText(projectstatus);
}
// write the file:
java.io.FileWriter output = new java.io.FileWriter( path );
doc.write( output );
output.close();
out.write("\r\n\r\n");
out.write("<html>\r\n ");
out.write("<head>\r\n ");
out.write("<title>Success");
out.write("</title>\r\n ");
out.write("</head>\r\n ");
out.write("<body bgcolor=\"lightblue\">");
out.write("<font size=\"5\">\r\n Project list successfully modified.");
out.write("</font>");
out.write("<br />\r\n ");
out.write("<hr>\r\n ");
out.write("<a href=\"ViewProj_list.jsp\">Back to Project List");
out.write("</a>   \r\n ");
out.write("<a href=\"EditProj.jsp\">Add another record");
out.write("</a>\r\n ");
out.write("</body>\r\n");
out.write("</html>");
} catch (Throwable t) {
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (pageContext != null) pageContext.handlePageException(t);
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
}
}
}
If you can help me debug my error please...
Thanx..
18 years ago
When I click on my edit button, it gives an error like this...What does it mean???
org.apache.jasper.JasperException
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)

root cause
java.lang.NullPointerException
at org.apache.jsp.AddProj_jsp._jspService(AddProj_jsp.java:102)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)
Thank You... :roll:
18 years ago