I have a simple class asdf in package foo.bar:
I'm trying to write a servlet to call the class
When i import foo.bar into the servlet i get: "package foo does not exist".
my dir structure is:
webapps/site/WEB-INF/classes/servletTest
webapps/site/WEB-INF/classes/foo/bar/asdf
Is this not possible? What am i doing wrong?
My goal is to have a class that both my jsp and servlets can call.
Code:
package foo.bar;
public class asdf
{
private String val;
public asdf()
{
val = "";
}
public void setValue(String v)
{
val = v;
}
public String getValue()
{
return val;
}
}
I'm trying to write a servlet to call the class
Code:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import foo.bar;
public class servletTest extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
asdf testing = new asdf();
testing.setValue("hello from servlet!");
out.println(test.getValue());
}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
doGet(request, response);
}
}
When i import foo.bar into the servlet i get: "package foo does not exist".
my dir structure is:
webapps/site/WEB-INF/classes/servletTest
webapps/site/WEB-INF/classes/foo/bar/asdf
Is this not possible? What am i doing wrong?
My goal is to have a class that both my jsp and servlets can call.