Marcus Dryice Koh
Marcus Dryice Koh

Reputation: 117

Get location of folder in jsp

I have this jsp page where it calls the servlet class.In this servlet class it calls another java class.This java class is then attempting to locate a folder named "profiles".However when I tried running the jsp page on a browser it keeps returning ClassNotFoundException(Is it caused by specifying the wrong directory or missing JAR files?).The question I am asking is:How do I get the correct pathing of that folder?

EDIT:
Here is the code:
In UserClientSearch.jsp:

    <form id="form" method="post" action="UserClientServlet">

In UserClientServlet.java:

    String value = request.getParameter("screenName");
    request.setAttribute("screenName", value);

    UserClientFilterSpam fs = new UserClientFilterSpam();
    ArrayList<String> content= fs.filterSpam(value);

In UserClientFilterSpam.java:

        try {
        lds.init("profiles");
    } catch (LangDetectException ex) {
        System.out.println("Error encountered: "+ ex);
    }

Here is the stacktrace:

SEVERE: Servlet.service() for servlet [servlet.UserClientServlet] in context with path [/MarcusFYPJ] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: com.cybozu.labs.langdetect.LangDetectException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    at servlet.UserClientServlet.doPost(UserClientServlet.java:47)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

Upvotes: 1

Views: 510

Answers (1)

Reimeus
Reimeus

Reputation: 159864

The error is being caused by the fact that com.cybozu.labs.langdetect.LangDetectException is missing from the classpath.

You need to make sure that it is included in the deployed web application. If it is a 3rd party JAR file it can reside in the web app's WEB-INF/lib folder.

Upvotes: 1

Related Questions