• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlets classes and borkers classes not compiling!

 
Gloria Hans
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everyone,
I am using servlets and jsp to publish a database to an intranet . My problem is that my servlets are not compiling. I am having this error when I complile my servlet :
C:\Tomcat\Tomcat\webapps\CoreData\WEB-INF\classes\ProjectServlet.java:38: package broker does not exist
private broker.RelationBroker rb = broker.RelationBroker.getRelationBroker();
And when I compile a broker class I have this error:
C:\Tomcat\Tomcat\webapps\CoreData\WEB-INF\classes\broker\ProjectBroker.java:157: package core does not exist
core.Project dr = new core.Project();
I have a package called "broker" for my brokers and anpther package called "core' for my bean classes in my classes package. i don't know why it's not compiling.
As a result I can't test my program since when I call my servlet class from my jsp page, the servlet class is not found because it has not been compiled.
Here is how my servlet class looks like:

import java.io.*;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ProjectServlet extends HttpServlet
{
//Variables here
private broker.RelationBroker rb = broker.RelationBroker.getRelationBroker();
private Connection con = rb.getConnection();

/*
Description: This method is used to print out the display table
Parameter: HttpServletRequest request
Parameter: HttpServletResponse response
Return: none
*/
public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException
{
HttpSession session = request.getSession();
response.setContentType("text/html");
PrintWriter out = response.getWriter();
System.out.println("hi Marcy");
request.setAttribute("session", session);
gotoPage("http://nepru", request, response);

}
// Method to get the request dispatcher and forward the request to the following address
public void gotoPage(String address, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(address);
dispatcher.forward(request, response);
}
// Method to close the db connection.
public void destroy()
{
try{
con.close();}
catch(SQLException sqle){
System.out.println("SQL error" + sqle.getMessage());
sqle.printStackTrace();}
}
My web-inf is organzied as:
web-inf\classes and web-inf\web.xml
classes\broker (contains broker classes)
classes\core (contains bean classes)
classes\servlets classes (not in a package)
The only broker class that compile is my relationalbroker that establishes the connection to the database.
But then I have to call that class from my servlet classes and y other borker classes but it doesn't seem to be able to see that class, or to see my bean classes.
Please help
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why did you place you classes folder under your web application folder? It will make the users be able to get your classes, if they know the URL...
I mean all of the classes under WEB-INF is enough for a web application...
I think the reason why you got such Package Not Exist error is that you have to create them under WEB-INF.... And it seems like there is a deadlock between two packages...
Hope you can find the solution...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic