Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What to do with this???

Status
Not open for further replies.

TyzA

Programmer
Jan 7, 2002
86
BE
Hi,

When I compile my About.java file, I get tons of error message. they all look like this and have something to do with the imports.
The strange thing is that it is only for this file. Other servlets compile well.

ERROR:
------
About.java:24: 'class' or 'interface' expected
import java.sql.*;

CODE:
-----

package com.comparitel.web.general;

//=============================== Imports ============================
import java.io.*;
import java.sql.*;

import javax.servlet.*;
import javax.servlet.http.*;

import com.comparitel.util.*;
import com.comparitel.core.*;
import com.comparitel.db.*;
import com.comparitel.appint.*;

import com.comparitel.web.util.*;

import com.javaexchange.dbConnectionBroker.*;

public class About extends HttpServlet{

//============================ Declarations =======================
public String strTittle="", strMailTo="", strParam="";

//=========================== Public Methods ======================

/*-----------------------------------------------------------------
* Method: doGet
* Description: This method will catch all incomming requests from the GUI
*-----------------------------------------------------------------*/
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {

String strMethod = "About.doGet";
StringBuffer strHtml = new StringBuffer();

PrintWriter out = res.getWriter();

String strMailTo = req.getParameter("emailTo");

boolean b = getDetails(strMailTo);

if ( b )
{
res.setContentType("text/html");

// get DB connection and log object
DbConnectionBroker pool = (DbConnectionBroker) getServletContext().getAttribute(Global.CONTEXT_CONN_POOL);
Log log = (Log) getServletContext().getAttribute(Global.CONTEXT_LOG);

Connection conn = pool.getConnection();

if ( conn!=null )
{
strHtml.append(&quot;<html>\n&quot;);
strHtml.append(&quot;<head>\n&quot;);
strHtml.append(&quot;<title>\n&quot;);

strHtml.append(strTittle);

strHtml.append(&quot;</title>\n&quot;);
strHtml.append(&quot;<link rel=\&quot;stylesheet\&quot; type=\&quot;text/css\&quot; href=\&quot;css-lib/Comparitel_All.css\&quot;>\n&quot;);
strHtml.append(&quot;<SCRIPT LANGUAGE=\&quot;JavaScript\&quot; SRC=\&quot;scripts/ValidateCustomerForm.js\&quot;></SCRIPT>\n&quot;);
strHtml.append(&quot;</head>\n&quot;);
strHtml.append(&quot;<body leftmargin=\&quot;0\&quot; topmargin=\&quot;0\&quot; marginwidth=\&quot;0\&quot; marginheight=\&quot;0\&quot;>\n&quot;);
strHtml.append(&quot;<table width=\&quot;750\&quot; cellspacing=\&quot;0\&quot; cellpadding=\&quot;0\&quot; border=\&quot;0\&quot; leftmargin=\&quot;0\&quot; topmargin=\&quot;0\&quot; marginwidth=\&quot;0\&quot; marginheight=\&quot;0\&quot;>\n&quot;);
strHtml.append(&quot;<tr><td colspan=\&quot;3\&quot; align=\&quot;center\&quot;>\n&quot;);
strHtml.append(&quot;<img src=\&quot;images/general/spacer.gif\&quot; alt=\&quot;\&quot; width=\&quot;1\&quot; height=\&quot;40\&quot; border=\&quot;0\&quot;>\n&quot;);
strHtml.append(&quot;</td></tr><tr>\n&quot;);
strHtml.append(&quot;<td rowspan=\&quot;2\&quot;>\n&quot;);
strHtml.append(&quot;<img src=\&quot;images/general/spacer.gif\&quot; alt=\&quot;\&quot; width=\&quot;10\&quot; height=\&quot;1\&quot; border=\&quot;0\&quot;>\n&quot;);
strHtml.append(&quot;</td>\n&quot;);
strHtml.append(&quot;<td class=\&quot;green\&quot; colspan=\&quot;2\&quot;>\n&quot;);
strHtml.append(&quot;<strong>\n&quot;);

strHtml.append(strTittle);

strHtml.append(&quot;</strong>\n&quot;);
strHtml.append(&quot;<br><br>\n&quot;);
strHtml.append(&quot;Tell us what you think &quot;);

strHtml.append(strTittle);

strHtml.append(&quot;<br><br>\n&quot;);
strHtml.append(&quot;You can fill in the form or contact us directly at: <a class=\&quot;green\&quot; tabindex=\&quot;1\&quot; href=\&quot;mailto:&quot;);
strHtml.append(strMailTo);
strHtml.append(&quot;\&quot;>&quot;);

strHtml.append(strMailTo);

strHtml.append(&quot;</a>\n&quot;);
strHtml.append(&quot;<br><br> </td></tr><tr>\n&quot;);
strHtml.append(&quot;<td class=\&quot;green\&quot; >\n&quot;);
strHtml.append(&quot;<form method=\&quot;POST\&quot; name=\&quot;ctForm\&quot; onSubmit=\&quot;return ValidateForm('contact')\&quot; action=\&quot;sentmail\&quot;>\n&quot;);
strHtml.append(&quot;Email address: <br>\n&quot;);
strHtml.append(&quot;<input class=\&quot;contact\&quot; type=\&quot;text\&quot; name=\&quot;email\&quot; size=\&quot;65\&quot; tabindex=\&quot;2\&quot;><br>\n&quot;);
strHtml.append(&quot;<br>\n&quot;);
strHtml.append(&quot;Comment: <br>\n&quot;);
strHtml.append(&quot;<textarea class=\&quot;contact\&quot; cols=\&quot;67\&quot; rows=\&quot;10\&quot; name=\&quot;message\&quot;></textarea><br>\n&quot;);
strHtml.append(&quot;<input class=\&quot;greenBtn\&quot; type=\&quot;submit\&quot; name=\&quot;send\&quot; value=\&quot;Send\&quot;>\n&quot;);

strHtml.append(&quot;<input class=\&quot;greenBtn\&quot; type=\&quot;hidden\&quot; name=\&quot;mailTo\&quot; value=\&quot;&quot;);
strHtml.append(strParam);
strHtml.append(&quot;\&quot;>\n&quot;);

strHtml.append(&quot;</td>\n&quot;);
strHtml.append(&quot;<td class=\&quot;green\&quot; width=\&quot;150\&quot;> \n&quot;);
strHtml.append(&quot;</td></tr></table></form></body></html>\n&quot;);

pool.freeConnection(conn);
out.println(strHtml.toString());
}
else
{
System.out.println(&quot;No Connection object - &quot;+strMethod);
log.out(strMethod,Global.LOG_ERR,&quot;no connection&quot;,conn);
}
}
else
{
System.out.println(&quot;Error while setting the parameters&quot;);
log.out(strMethod,Global.LOG_ERR,&quot;Error while setting the parameters&quot;,conn);
}// end boolean check
} // end doget

public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {

ServletContext context = getServletContext();

String strHost = (String)context.getAttribute(Global.MAIL_HOST);
String strUsr = (String)context.getAttribute(Global.MAIL_USR);
String strPwd = (String)context.getAttribute(Global.MAIL_PWD);
String strSMTP = (String)context.getAttribute(Global.MAIL_SMTP);

PrintWriter out = res.getWriter();
String strMethod = &quot;About.doPost&quot;;
StringBuffer strHtml = new StringBuffer();

String strMailFrom = req.getParameter(&quot;email&quot;);
String strMsg = req.getParameter(&quot;message&quot;);
String strParm = req.getParameter(&quot;mailTo&quot;);

boolean b = getDetails(strParm);

Mail mail = new Mail();

mail.mailFrom = strMailFrom;
mail.host = strHost;
mail.sendHost = strSMTP;
mail.mailUser = strUsr;
mail.mailPwd = strPwd;
mail.mailTo = strMailTo;

mail.sendMail(strTittle,strMsg);

strHtml.append(&quot;<html>\n&quot;);
strHtml.append(&quot;<head>\n&quot;);
strHtml.append(&quot;<title>[tittle from the global file]</title>\n&quot;);
strHtml.append(&quot;<link rel=\&quot;stylesheet\&quot; type=\&quot;text/css\&quot; href=\&quot;css-lib/Comparitel_All.css\&quot;>\n&quot;);
strHtml.append(&quot;</head>\n&quot;);
strHtml.append(&quot;<body leftmargin=\&quot;0\&quot; topmargin=\&quot;0\&quot; marginwidth=\&quot;0\&quot; marginheight=\&quot;0\&quot;>\n&quot;);
strHtml.append(&quot;<table width=\&quot;750\&quot; cellspacing=\&quot;0\&quot; cellpadding=\&quot;0\&quot; border=\&quot;0\&quot; leftmargin=\&quot;0\&quot; topmargin=\&quot;0\&quot; marginwidth=\&quot;0\&quot; marginheight=\&quot;0\&quot;>\n&quot;);
strHtml.append(&quot;<tr><td colspan=\&quot;3\&quot; align=\&quot;center\&quot;>\n&quot;);
strHtml.append(&quot;<h1>Thanks for you comment<h1>\n&quot;);
strHtml.append(&quot;</td></tr></table></form></body></html>\n&quot;);

out.println(strHtml.toString());

} // end doPost

public boolean getDetails(String strMailTo)
{
if ( strMailTo!=null && strMailTo.equals(Global.ABOUT_US) )
{
strTittle=Global.CONTACT_TITTLE_AU;
strMailTo=Global.MAIL_ADDR_INFO;
strParam=Global.ABOUT_US;
}
else
return false;

if ( strMailTo!=null && strMailTo.equals(Global.ABOUT_BC) )
{
strTittle=Global.CONTACT_TITTLE_BC;
strMailTo=Global.MAIL_ADDR_BC;
strParam=Global.ABOUT_BC;
}
else
return false;

if ( strMailTo!=null && strMailTo.equals(Global.ABOUT_BA) )
{
strTittle=Global.CONTACT_TITTLE_BA;
strMailTo=Global.MAIL_ADDR_BA;
strParam=Global.ABOUT_BA;
}
else
return false;

if ( strMailTo!=null && strMailTo.equals(Global.ABOUT_CS) )
{
strTittle=Global.CONTACT_TITTLE_CS;
strMailTo=Global.MAIL_ADDR_CS;
strParam=Global.ABOUT_CS;
}
else
return false;

return true;

} // end getDetails

} // end class
 
Ok, this probel is fixed. Stupid typo.

But I've got a new error (same code as above):

About.java:164: cannot access com.comparitel.web.util.MailServlet
bad class file: C:\Program Files\Apache Group\Tomcat 4.1\webapps\comparitel\WEB-
INF\classes\com\comparitel\web\util\MailServlet.class
class file contains wrong class: MailServlet
Please remove or make sure it appears in the correct subdirectory of the classpath.
MailServlet mail = new MailServlet();
^
1 error

Thanks for any info

T.
 
MailServlet is the new name for Mail
 
It doesn't seem likely that the problem is in About.java. I would examine MailServlet to make sure no errors were made renaming it from Mail, and perhaps delete your class files and recompile everything.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top