aspose file tools*
The moose likes Servlets and the fly likes Cannot compile servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Cannot compile servlet" Watch "Cannot compile servlet" New topic
Author

Cannot compile servlet

Eva Tang
Greenhorn

Joined: Oct 06, 2003
Posts: 12
Hi,
I have a JSP application that makes use of a formbean and servlet. The formbean validate the data then pass to the servlet to do database query. The formbean works but I cannot get the servlet that use the formbean to compile.
Any idea? Thanks in advance!
Eva
Here is the code for my DBHandler servlet:
package calendar;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;
import calendar.*;
public class DBHandler extends HttpServlet
{
static ResultSet result;
static Statement stmt;
static Connection conn;
String sql;
public void doPost (HttpServletRequest request, HttpServletResponse response)
{
try {
FormBean f = (FormBean) request.getAttribute("formHandler");
} catch (Exception ex)
{
ex.printStackTrace();
}
}
}
The error I get when I compile DBHandler.java
DBHandler.java:19: cannot resolve symbol
symbol : class FormBean
location: class calendar.DBHandler
FormBean f = (FormBean) request.getAttribute("formHandler");
^
DBHandler.java:19: cannot resolve symbol
symbol : class FormBean
location: class calendar.DBHandler
FormBean f = (FormBean) request.getAttribute("formHandler");
^
2 errors
My file directory are as follow:
tomcat_home:
|-webapps
|
|-calendar
|
|-jsp
|
|-(all the *.jsp files)
|-WEB-INF
|
|-classes
|
|-calendar.properties
|-calendar
|-FormBean.class
|-DBHandler.java
Eva Tang
Greenhorn

Joined: Oct 06, 2003
Posts: 12
My file directory are as follow:
tomcat_home:
|-webapps
---|
---|-calendar
-------|
-------|-jsp
----------|
----------|-(all the *.jsp files)
-------|-WEB-INF
----------|
----------|-classes
----------|
----------|-calendar.properties
----------|-calendar
--------------|-FormBean.class
--------------|-DBHandler.java
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Given that directory structure, FormBean should also have a "package calendar" statement -- does it? If so, then make sure your compile command makes sense; i.e., if run javac from WEB-INF/classes as
javac calendar\*.java
(assuming "." and servlet.jar are on your class path).


[Jess in Action][AskingGoodQuestions]
Eva Tang
Greenhorn

Joined: Oct 06, 2003
Posts: 12
Oh I guess I need to compile the formbean and the DBhandler files together. It works when I compile using
javac calendar\*.java
but not when I compile only the calendar\DBHandler.java
good to learn sometime! Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot compile servlet