• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot compile servlet

 
Eva Tang
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Eva Tang
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic