• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

Cannot compile servlet

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and iconoclast
Posts: 24208
47
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
The only cure for that is hours of television radiation. And this tiny ad:
Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders
https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing
reply
    Bookmark Topic Watch Topic
  • New Topic