LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   unable to compilation class for jsp in tomcat 8.1 (https://www.linuxquestions.org/questions/linux-newbie-8/unable-to-compilation-class-for-jsp-in-tomcat-8-1-a-4175547790/)

amrit21 07-12-2015 03:00 AM

unable to compilation class for jsp in tomcat 8.1
 
Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
        margin-left: 0px;
        margin-top: 0px;
        margin-right: 0px;
        margin-bottom: 0px;
        background-color: #FFFF66;
}
-->
</style></head>


<%@ page import="java.sql.*;"%>
<jsp:useBean id="obj" class="p1.DBInfo"/>
<body>
<center>
  <%
    String s1=request.getParameter("fname");
    String s2=request.getParameter("pass");
    int i=obj.checkLogin(s1, s2);
    if(i==1)
    {
    response.sendRedirect("admin.jsp");
    }
    if(i==2)
    {
  %>
    <jsp:forward page="faculty.jsp" />
  <%
  }
  if(i==3)
  {
    response.sendRedirect("student.jsp");
  } 
  if(i==0)
  {
    %>
    <font color="Red">Invalid username or password!</font>
    <jsp:include page="Login.html" />
    <%
    }
    %>
</center>
</body>
</html>


Code:

package p1;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class DBInfo
{
  static Connection con=null;
  static
  {
          //Drivers
                  try
                  {
                        Class.forName("com.mysql.jdbc.Driver");
                        System.out.println("Driver loaded");
                  }
                  catch (ClassNotFoundException e)
                  {               
                        e.printStackTrace();
                  }
                  System.out.println("Driver loaded");
  }
  public static Connection getConnection()
  {
         
          String url="jdbc:mysql://localhost:3306/collegedb";
          String username="root";
          String password="rat";
          try
          {
                con=DriverManager.getConnection(url,username,password);
                System.out.println("Connection established:"+con);
          }
          catch (SQLException e)
          {
                e.printStackTrace();
          }
          return con; 
  }
  public static void close()
  {
            try
            {
                con.close();
            }
            catch (SQLException e)
            {
                e.printStackTrace();
            }
  }
  public int checkLogin(String s1,String s2)
  {
         
      int flag=0;
      int value=0;
      String usertype="";
          getConnection();
          try
          {
                  String query="select * from login where username=? and password=?";
                        PreparedStatement ps=con.prepareStatement(query);
                        ps.setString(1,s1);
                        ps.setString(2,s2);
                        ResultSet res=ps.executeQuery();
                        while(res.next())
                        {
                        flag=1;
                        usertype=res.getString(4);
                        break;
                        }
                        if(flag==1 && usertype.equalsIgnoreCase("admin"))
                        {
                          value=1;
                        }
                        if(flag==1 && usertype.equalsIgnoreCase("faculty"))
                        {
                          value=2;
                        }
                        if(flag==1 && usertype.equalsIgnoreCase("student"))
                        {
                          value=3;
                        }
                        if(flag==1 && usertype.equalsIgnoreCase("other"))
                        {
                          value=4;
                        }
                        if(flag==0)
                        {
                                value=0;
                        }
                       
          }
          catch(Exception e)
          {
                  e.printStackTrace();
          }
          return value;
  }
}

Code:


type Exception report

message org.apache.jasper.JasperException: Unable to compile class for JSP

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to compile class for JSP
        org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:555)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause

org.apache.jasper.JasperException: Unable to compile class for JSP
        org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:600)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause

java.lang.IllegalArgumentException: Page directive: invalid value for import
        org.apache.jasper.compiler.Node$PageDirective.validateImport(Node.java:610)
        org.apache.jasper.compiler.Node$PageDirective.addImport(Node.java:591)
        org.apache.jasper.compiler.Parser.parsePageDirective(Parser.java:344)
        org.apache.jasper.compiler.Parser.parseDirective(Parser.java:458)
        org.apache.jasper.compiler.Parser.parseFileDirectives(Parser.java:1782)
        org.apache.jasper.compiler.Parser.parse(Parser.java:136)
        org.apache.jasper.compiler.ParserController.doParse(ParserController.java:227)
        org.apache.jasper.compiler.ParserController.parseDirectives(ParserController.java:117)
        org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:194)
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
        org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.22 logs.


schneidz 07-23-2015 09:27 PM

Welcome to LQ! We'd very much like to help, but your current thread makes that difficult. Please visit http://www.linuxquestions.org/questi...#faq_lqwelcome for some additional information on how you can help us help you. If you have any questions or need additional clarification, just let us know.


All times are GMT -5. The time now is 03:25 AM.