JSP basics: import a Java class for use in a JSP

Contributor Icon Contributed by qmchenry Date Icon March 11, 2004  
Tag Icon Tagged: JSP programming

Importing Java classes enables the use of that class without using the fully qualified class name. Java classes can also be imported into JSPs with page directives.


To import the Java class java.util.Calendar for use in a JSP, use one of the following:

<%@page import="java.util.Calendar"%>

Previous recipe | Next recipe |
 
  • 102
    thanks a lot :D
  • george
    If you wrote your own class where do you put it in the file system to access it from JSP?
  • ShadowCat8
    If you are using the Apache Tomcat server to serve up your JSP pages, then I would recommend putting your own class packages in ${TOMCAT_BASE}/common/lib/

    For our implementation here, it's /opt/tomcat5/common/lib/.

    HTH. Enjoy.
blog comments powered by Disqus