creating an object within a jsp page

11,395

Solution 1

Try adding a space like:

<%@ page import="com.servlet.java.*"%>

And make sure if the file comes from a jar, put the jar into the lib.

Solution 2

Why do not you use Beans:

<jsp:useBean id="VarName" class="BackendServer"  scope = *page | request | session |application*/>

Solution 3

write the fully qualified name. com.servlet.java.BackendServer is your class?

are you sure the jar of this class is in classpath of this web app?

where is the jar?

where is the app.

should be in common lib, global app container classpath or this web apps path

Share:
11,395
kholofelo Maloma
Author by

kholofelo Maloma

Love coding

Updated on June 04, 2022

Comments

  • kholofelo Maloma
    kholofelo Maloma almost 2 years

    I am developing a web app. I have a disptacher servlet which successfully calls a JSP page, but this JSP has to read data from some other object... but it would find it...

    this is the line which wont locate "BackendServer" class. It gives me a ClassNotFoundException error...

      <%=new BackendServer().run("getCar")%>
    

    basically the above line of code is within the JSP... if I remove it, the app runs well without the output of this line

    I have imported BackendServer on top this way:

      <%@page import="com.servlet.java.*"%>
    

    how can I make my JSP find my BackendServer?

    thanks in advance :)