Java classes not accessible

0 votes
asked Dec 14, 2010 by harish

I am trying to build a dynamic web app using Eclipse Helios. I am trying to use a java class inside a jsp page. The page is visible during coding and deployment. In the runtime the java classes are not resolved to a type. Why does this happen?

Update: Directory structure as in eclipse

 Restarunt JAX-WS Web Services
 Deploymment Descriptor Java
     default package
       LoginBean build WebContent    WebINF
      weblogic.xml jsp files

3 Answers

0 votes
answered Dec 14, 2010 by pablo-santa-cruz

If FQN of your class is your.package.YourClass then make sure your class deploys to:

    WEB-INF \
        classes \
            your \
               package \
0 votes
answered Dec 14, 2010 by jigar-joshi

Have you added in jsp, and this classes are in class path or is in the WEB-INF/classes after build

<%@ page import="java.util.*,yourpackage.yourClass" %>
0 votes
answered Dec 14, 2010 by balusc

Classes in the default package are invisible/unimportable by classes in a package. JSP files end up as a class in a package, so it will be invisible to JSP as well. This works in very specific (Tomcat) environments only, you don't want to be dependent on that. Just put classes in a package. Always.

Unrelated to the problem, writing Java code in a JSP is a poor practice. Use a Servlet.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter