how to reference a java .class file from a JSP page?

前端 未结 5 2050
再見小時候
再見小時候 2020-12-19 23:12

I have the JSP file (/page.jsp) in the root of my app directory. I want to use this class located in /WEB-INF/classes/Helper.class.

I tried using the JSP page impo

5条回答
  •  轮回少年
    2020-12-19 23:39

    It has to be in the CLASSPATH of your WAR - either a package under WEB-INF or JAR under WEB-INF/lib. That's just basic Java.

    The object has to be in request, page, session, or application scope. This usually means that a servlet put it there. You've got to have a servlet and JSP collaborating to do it.

    You can write scriptlet code, but I think it's far better to use JSTL. Scriptlet-free JSPs are a good idea in the long run.

提交回复
热议问题