0

I am having a java file named FaceDetection.java that has a function named FaceDetectionMain and that take two arguments .The java file dont have any main function.Now i call this java class file function in my jsp page like this :

FaceDetection.FaceDetectionMain(imagepath,imagename);

But am getting an exception as follow :

Apr 21, 2014 10:44:23 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/SharedCrpto1] threw exception [Unable to compile class for JSP: 

An error occurred at line: 90 in the jsp file: /uploadwebcamimage.jsp
FaceDetection cannot be resolved
87:          fos.write(imageData);
88:          String imagepath=filesstore+"\\"+imagename+".png";
89:          
90:          Boolean flag=FaceDetection.FaceDetectionMain(imagepath,imagename);
91:         %>
92:     </body>
93: </html>


Stacktrace:] with root cause
org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 90 in the jsp file: /uploadwebcamimage.jsp
FaceDetection cannot be resolved
87:          fos.write(imageData);
88:          String imagepath=filesstore+"\\"+imagename+".png";
89:          
90:          Boolean flag=FaceDetection.FaceDetectionMain(imagepath,imagename);
91:         %>
92:     </body>
93: </html>

Please help me remove this exception. Full stackTrace for exception is :

at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:97)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:374)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:352)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:339)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:344)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:317)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:182)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311)
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)
6
  • It can't find FaceDetection, but maybe you understood that? Commented Apr 21, 2014 at 17:19
  • @ᴋᴇʏsᴇʀ But why ?FaceDetection java file is present in my default package. Commented Apr 21, 2014 at 17:20
  • @ᴋᴇʏsᴇʀ what you mean?I didnt get you Commented Apr 21, 2014 at 17:21
  • 1
    Did you import it to the page? <%@ page import="org.something.something.FaceDetection"%> Commented Apr 21, 2014 at 17:21
  • 1
    Your FaceDetection class may be in the default package, but the class that is generated by processing your .jsp file is not in the default package. Put your class in a package then reference it explicitly with an import from your jsp as your.package.FaceDetection — also, calling Java from a jsp is generally discouraged — send your data to the server (ajax maybe) and process it there, then make the results available to the jsp (maybe as a json response) Commented Apr 21, 2014 at 17:57

1 Answer 1

4

Using the default package isn't a good practice, and often causes problems such as the one you are having (you can't import the default package, so no need to try the page import directives) Try putting your class in a package and import it, you should find that it works properly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.