either include your class in classpath for the server or put your class in
WEB-INF/classes directory.  This way the server will resolve the classes for
the servlet when your servlet is loaded.

Gang

----- Original Message -----
From: "Carter, Scott" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 18, 2002 3:46 PM
Subject: Including java classes in Servlet


>          Can you write your own java classes (not servlets, just simple
java
> classes ) and then use the functionality of those classes in your servlet?
> I wrote a class that just does some simple things such as returning an
array
> and tryed to use this class in my servlet.  I included the class in the
> classpath when I compiled the servlet, and that worked just fine, but when
I
> access the page I get the following error :
>
>         root cause
> java.lang.NoClassDefFoundError: com/ae/rtu/RTUlist
>         at GreetingServlet.doGet(GreetingServlet.java:30)
>
>
> BELOW IS THE CODE OF THE SERVLET :
>
> import java.io.*;
> import java.util.*;
> import java.sql.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> import com.ae.rtu.*;
>
> public class GreetingServlet extends HttpServlet {
>
>         public void doGet (HttpServletRequest request,
>                        HttpServletResponse response)
>                         throws ServletException, IOException
>         {
>         response.setContentType("text/html");
>         response.setBufferSize(8192);
>         PrintWriter out = response.getWriter();
>
>         // then write the data of the response
>         out.println("<html>" + "<head><title>RTU LIST</title></head>");
>                 out.println("<body>");
>                 out.println("HELLO Hello<BR>");  // Just a test print to
see
> if servlet is working
>
>                 RTUlist r = new RTUlist();
>                 RTU[] RTUs = r.returnTestRTUarray();
>
>
>                 out.println("</body></html>");
>         out.close();
>         }
>  }
>
> BELOW IS THE CODE OF MY SIMPLE JAVA CLASS :
>
> package com.ae.rtu;
>
> import java.io.*;
> import java.util.*;
>
>
>
> public class RTUlist
> {
>         public void returnRTUarrayFromFile (File f)
>         {
>
>         }
>
>         public RTU[] returnTestRTUarray ()     // This will be a test
method
>         {
>                 RTU[] RTUarray = new RTU[3];
>                 RTUarray[1].setValues("testRTU1", 1, 1, 1, 1, 2, "T1",
> "MPS", 9600, "QEI", 8);
>                 RTUarray[2].setValues("testRTU2", 1, 2, 1, 1, 2, "T2",
> "Harris", 9600, "QEI", 8);
>                 RTUarray[3].setValues("testRTU3", 1, 3, 5, 7, 9, "T3",
> "MPS", 1200, "XXX", 8);
>
>
>
>                 return RTUarray;
>
>         }
> }
>
>
> THANKS FOR ANY HELP WITH THIS !!!!
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to