Hello,
I am receiving this error:
java.lang.Exception: XSP Java Compiler: Compilation failed for _newUser.java
72: Type expected.
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
^
240: Identifier expected.
xspParentNode = xspCurrentNode;
----- ^
The ligne 72: points to isIDduplicate()
function while the line 240 points to if-else.
I am using cocoon 1.8.2 and Tomcat3.2.1
Here is my code (this program is for form handling):
<?xml version="1.0"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="../../userFactory.xsl" type="text/xsl"?>
<xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core">
<xsp:structure>
<xsp:include> java.lang.*</xsp:include>
<xsp:include> java.sql.*</xsp:include>
<xsp:include>java.sql.Date</xsp:include>
<xsp:include> java.sql.DriverManager</xsp:include>
<xsp:include> java.sql.SQLException</xsp:include>
<xsp:include>java.sql.Connection</xsp:include>
<xsp:include>java.sql.ResultSet</xsp:include>
<xsp:include>java.sql.Statement</xsp:include>
</xsp:structure>
<xsp:logic>
String fname = request.getParameter("fname")
...//some more request.getParameter()
String email = request.getParameter("email")
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String serverName =request.getServerName();
String
URL="jdbc:mysql://"+serverName+"/ILSDB?user=Bobo&password=BoboPassword";
Connection con = DriverManager.getConnection(URL, "", "" );
Statement stmt1=
con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATAB
LE);
Statement stmt2=
con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATAB
LE);
<![CDATA[
public boolean errorEntries()
{
boolean checked=false;
if (fname.equals("") || lname.equals("") || login.equals("")
|| password.equals("") || REpassword.equals("") || email.equals("")
|| !password.equals(REpassword) || country.equals("")
||company.equals("")
|| ophone.equals("") || address.equals("") || emaiCheck() ||
isIDduplicate() )
{
ckecked=true;
}
return checked;
}
public boolean isIDduplicate()
{
boolean duplicateKey=false;
try
{
ResultSet uprs1 = stmt1.executeQuery("SELECT * FROM user");
while (uprs1.next())
{
duplicateUserID=uprs21.getString("user_id");
if( login.equalsIgnoreCase(duplicateUserID) )
{
duplicateKey = true;
break;
}
}
uprs1.close();
stmt1.close();
//con.close();
return duplicateKey;
}
catch(SQLException ex)
{
System.err.println("SQLException: " + ex.getMessage());
}
}
public boolean emaiCheck()
{
boolean isEmailValid=false;
if (email.equals("") )
{
return isEmailValid;
}
else
{
char emailCharArray[] = email.toCharArray();
for(int i=0; i<emailCharArray.length; i++)
{
if(emailCharArray[i]==' ' || emailCharArray[i]=='-')
{
return isEmailValid;
}
else if (emailCharArray[i]=='@')
{
int j=i;
String mailserverName = email.substring(j+1);
if( !mailserverName.startsWith(".") )
{
char mailserverCharArray[] = mailserverName.toCharArray();
for(int k=0; k<mailserverCharArray.length; k++)
{
if (mailserverCharArray[k]=='.')
{
int t=k;
String mailServerNameEnd=mailserverName.substring(t);
if(!mailServerNameEnd.endsWith(".") )
{
isEmailValid = true;
break;
}
}
}
}
}
}
}
return isEmailValid;
}
public boolean addUser()
{
try
{
ResultSet uprs2 = stmt2.executeQuery("SELECT * FROM user");
uprs2.moveToInsertRow();
uprs2.updateString("user_fname", fname);
uprs2.updateString("user_lname", lname);
uprs2.updateString("user_email", email);
uprs2.updateString("user_id", login);
uprs2.updateString("user_password", password);
uprs2.updateString("user_country", country);
uprs2.updateString("user_state", state);
uprs2.updateString("user_company", company);
uprs2.updateString("user_post", function);
uprs2.updateString("user_company_address", address);
uprs2.updateString("user_office_phone", ophone);
uprs2.updateString("user_house_phone", hophone);
uprs2.updateString("user_hand_phone", haphone);
uprs2.insertRow();
uprs2.close();
stmt2.close();
con.close();
return true;
}
catch(SQLException ex)
{
System.err.println("SQLException: " + ex.getMessage());
}
}
]]>
<userFactory>
if (errorEntries())
{
if (fname.equals(""))
{
<xsp:content>
<row>
<name>First Name</name>
<img>
<border>0</border>
<src>IMG/warningSign.gif</src>
<width>23</width>
<height>11</height>
</img>
<field input="yes" name="fname"/>
<status color="#800000">The first name field
should be filled</status>
</row>
</xsp:content>
}
else
{
<xsp:content>
<row>
<name>First Name</name>
<img>
<border>0</border>
<src>IMG/requiredField.jpg</src>
<width>15</width>
<height>15</height>
</img>
<field input="yes" hasValue="yes"
name="fname"><xsp:expr>fname</xsp:expr></field>
<status color="#295A84">The asterisk shows
required fields.</status>
</row>
</xsp:content>
}
...//some more if-else inside if (errorEntries())
else if (!errorEntries())
{
<xsp:expr>addUser()</xsp:expr>
<xsp:content>
<row>
<message>Record added!!</message>
</row>
</xsp:content>
}
<register-button/>
</userFactory>
</xsp:logic>
</xsp:page>
---------------------
I need your help.
Thank you.
Bobo,
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>