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..