简体   繁体   中英

error in running jsp file in tomcat?

I am trying to run a jsp file (test1.jsp) on tomcat server and it gives error!!
test1.jsp:

<html>
   <head><title>Hello World</title></head>
     <body>
       Hello World!<br/>    
      <%@ page import="neww.*" %>
      <% Simple demo = new Simple();
      out.println("Current date : " + demo.retur());%>
      <%
         out.println("Your IP address is " + request.getRemoteAddr());
      %>
     </body>
</html>

Simple.java:

package neww;
import static com.hp.hpl.jena.query.ReadWrite.READ ;
import static com.hp.hpl.jena.query.ReadWrite.WRITE ;
import com.hp.hpl.jena.query.ReadWrite ;
import com.hp.hpl.jena.query.Dataset ;
import com.hp.hpl.jena.query.Query ;
import com.hp.hpl.jena.query.QueryExecution ;
import com.hp.hpl.jena.query.QueryExecutionFactory ;
import com.hp.hpl.jena.query.QueryFactory ;
import com.hp.hpl.jena.query.QuerySolution ;
import com.hp.hpl.jena.query.ResultSet ;
import com.hp.hpl.jena.tdb.TDBFactory ;
import com.hp.hpl.jena.query.ResultSetFormatter;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.vocabulary.*;
import java.util.Iterator;
import java.util.Scanner;
import com.hp.hpl.jena.sparql.sse.SSE ;
import com.hp.hpl.jena.update.* ;
import java.util.*;
public class Simple{
public String retur(){
/*String query1;
            query1="hjcooljohny75@gmail.com";
        //query1 = (String)(subjectentry.getText());
            String s="SELECT ?x WHERE { ?x <TO:> '"+query1+"'}";
          //   subjectoutput.setText(s);
            String directory = "MYDATABASES/DATA2" ;
            Dataset ds = TDBFactory.createDataset(directory) ;
            Model model = ds.getDefaultModel() ;
           ds.begin(ReadWrite.READ) ;
             QueryExecution qExec = QueryExecutionFactory.create(s, ds) ;
           ResultSet rs = qExec.execSelect() ;
           String x=rs.toString();
          String[] arr = null;

            while (rs.hasNext()) {
                QuerySolution qs = rs.next();
                String rds = qs.get("x").toString();
               // String em = (String)rs.getString(0);
               //arr = em.split("\n");
               //for (int i =0; i < arr.length; i++){
              return rds; 

           }
             //if(rs==null)
  */              //subjectoutput.setText("sorry!!");
     String s="hi";
     return s;
}
}

my directory structure is :
/check/WEB-INF/classes//neww/Simple.java
/check/WEB-INF/classes//neww/Simple.class error in tomcat:
`

javax.servlet.ServletException: java.lang.NoClassDefFoundError: Simple
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:905)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:834)
    org.apache.jsp.test1_jsp._jspService(test1_jsp.java:82)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)`

I think this error probably have to do with package , I am really stuck on this ...Help!!

You should check your classes directory under WEB-INF directory. It is clear from exception that server is trying to load your class but it is not available in class path.

your application structure should be something like this

APP_NAME WEB-INF classes Package structure -> you class file should be here..

In case you are deploying your app as war file then extract the war and check the class file location.

Generally eclipse create bin folder to store the class file check it if your class file is also there then change it to classes folder under WEB-INF

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM