[EMAIL PROTECTED] wrote:

> The specifics may vary from server to server, but in general you can you
> place the class anywhere.  However, your classpath must point to the
> directory containing the code.


This is not correct. All JSP 1.0 (and later) compliant servers look for
class files in two very well defined places: the WEB-INF/classes and
the WEB-INF/lib directories for the application. The first is for
class files and the second for class files packaged in JAR files.
In addition, some containers let you place class files and JAR files
in container-specific directories, but the two WEB-INF dirctories
are *always* used and should be your first choice.

> Also, remember to import your class in your
> JSP.
> <%@ page import="DBConnection" %>


This is true, and the reason for why you need to import a class that
is not declared to be in a package (i.e. that is part of the unnamed
default package) is described in more detail here:

   <http://java.oreilly.com/news/jsptips_1100.html>

Hans

> Hope this helps.
>      ~ Elena.
> ---------------------------
> Elena Tsifrina
> SYSCOM, Inc.
> www.syscom.com
>
>
>
>
>                     "Chauviaux, Patrick"
>                     <[EMAIL PROTECTED]       To:     [EMAIL PROTECTED]
>                     NISYS.COM>                    cc:
>                     Sent by: A mailing list       Subject:     Re: How to call a 
>user defined method from a
>                     about Java Server Pages        JSP
>                     specification and
>                     reference
>                     <[EMAIL PROTECTED]
>                     COM>
>
>
>                     02/27/02 10:11 AM
>                     Please respond to A
>                     mailing list about Java
>                     Server Pages
>                     specification and
>                     reference
>
>
>
>
>
>
> In fact, what I want to know is where do I have to put the
> DBConnection.class or do you have to change the classpath?
> Please help me.
>
> -----Original Message-----
> From: Chauviaux, Patrick [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 27, 2002 2:43 PM
> To: [EMAIL PROTECTED]
> Subject: How to call a user defined method from a JSP
>
>
> Hello,
>
> I am new to JSP so my question is perhaps not really interesting for you
> but
> I would appreciate if you could reply.
>
> I have created a JSP and a class DBConnection. I want to create an instance
> of that class in my JSP like this:
> <% DBConnection dbc = new DBConnection(); %>
> I use an Apache-Tomcat server and I have put the JSP and the
> DBConnection.class in the same directory ($TOMCAT\webapps\ROOT\)
>
> The problem is that when I test the JSP it can't find the class
> DBConnection. I have the following error:
>         org.apache.jasper.JasperException: Unable to compile class for JSP
>
>         An error occurred between lines: 150 and 158 in the jsp file:
> /SubscriptionHousehold.jsp
>
>         Generated servlet error:
>
> C:\jakarta-tomcat-4.0.2\work\localhost\_\SubscriptionHousehold$jsp.java:63:
> Class org.apache.jsp.DBConnection not
>         found.
>                  DBConnection dbc = new DBConnection();
>
> Can someone tell me what I have to do to be able to create an instance of
> DBConnection in my JSP? Is it possible? I hope it is.
>
> Best regards,
>
> Patrick
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com
>
>


--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com
JavaServer Pages        http://TheJSPBook.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to