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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

package question 1

Status
Not open for further replies.

vasah20

Programmer
Feb 16, 2001
559
US
My directory structure looks like this:

Directory of C:\SITEMI~1\WEB-INF\classes\CCT

06/17/2002 08:54a <DIR> .
06/17/2002 08:54a <DIR> ..
06/17/2002 08:52a 3,145 Admin.java
06/14/2002 01:58p 2,862 AdminCheck.clas
06/14/2002 01:58p 2,699 AdminCheck.java
06/14/2002 02:58p 743 Calendar.java
06/14/2002 03:25p 289 Counter.class
06/14/2002 03:25p 120 Counter.java

and Admin.java and AdminCheck.java each have

package CCT;

at the top.

Why does the following occur?
C:\SITEMI~1\WEB-INF\classes\CCT>javac Admin.java
Admin.java:27: cannot resolve symbol
symbol : class AdminCheck
location: class CCT.Admin
private static final AdminCheck ct = new AdminCheck();
^
Admin.java:27: cannot resolve symbol
symbol : class AdminCheck
location: class CCT.Admin
private static final AdminCheck ct = new AdminCheck();

Admin.java
Code:
package CCT; //for neatness sake

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;

public class Admin extends HttpServlet {
	private Connection c = null;
	private Statement s = null;

	//should work, since AdminCheck is in the same package
	private static final AdminCheck ct = new AdminCheck();

	public void doPost(HttpServletRequest req, HttpServletResponse res)
		throws ServletException, IOException {
		res.setContentType(&quot;text/html&quot;);
		PrintWriter out = res.getWriter();

		out.println(&quot;Authenticating user...<br />&quot;);
		//first we authenticate the session against what's in the DB
		HttpSession sess = req.getSession();
		if(sess.getAttribute(&quot;login.userName&quot;) != null) { //1st layer of verification
			out.println(&quot;UNAUTHORIZED USER&quot;);
			return;
		} //end if

		String sql = &quot;SELECT userid FROM CCT_AuthUsers WHERE UserLogin = '&quot; +
			sess.getAttribute(&quot;login.userName&quot;) + &quot;' AND sid = '&quot; + sess.getId() + &quot;'&quot;;


		try {
			Class.forName(&quot;sun.jdbc.odbc.JdbcOdbcDriver&quot;);
			c = DriverManager.getConnection(
					&quot;jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/Site Mirror/test.mdb&quot;,
					&quot;&quot;,&quot;&quot;);
			s = c.createStatement();
			ResultSet rs = s.executeQuery(sql);

			if(!rs.next()) {
				out.println(&quot;UNAUTHORIZED USER&quot;);
				return;
			} //end if

			//once we get here, we're validated and authorized
			int atype = Integer.parseInt(req.getParameter(&quot;atype&quot;));
			out.println(&quot;running!&quot;);

		} catch (ClassNotFoundException e) {
			out.println(&quot;Class not found!\n&quot; + e.getMessage() + &quot;\n&quot; + e.toString());
		} catch (SQLException e) {
			out.println(&quot;SQL Error occurred!\n&quot; + e.getMessage() + &quot;\n&quot; + e.toString());
		} finally {
			try {
				if(c != null) c.close();
			} catch (Throwable t) {
				out.println(&quot;Could not close connection&quot;);
			} //end try
		} //end try
	} //end doPost

	/**
	 * Necessary wrapper. Calls doPost
	 **/
	public void doGet(HttpServletRequest req, HttpServletResponse res)
		throws ServletException, IOException {
		doPost(req,res);
	} //end doGet

	private final void outputPage() {

	} //end outputPage
} //end Admin
leo

------------
Leo Mendoza
lmendoza-at-garbersoft-dot-net
 
Remember, package names need to correspond to directories so you will have to have the folder ABOVE CCT in your classpath. Since you are compiling in the CCT directory and probably only have '.' in the classpath by default, the compiler is not going to find the class. You need to add the parent directoy to the classpath or better yet, use the -D switch to put your class output somewhere else and make sure that that is in your classpath.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top