LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-12-2015, 03:00 AM   #1
amrit21
LQ Newbie
 
Registered: Jul 2015
Posts: 1

Rep: Reputation: Disabled
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.
 
Old 07-23-2015, 09:27 PM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Help with 'Unable to compile class for JSP' Jerry Mcguire Programming 2 03-16-2011 04:22 AM
[SOLVED] Compilation error trying to sub-class a Qt QAction class, not sure why rstewart Programming 2 02-08-2011 11:45 AM
Tomcat : unable to access the jsp pages minil Programming 11 01-28-2006 09:19 AM
about Jakarta Struts, Jsp's and Tomcat.... problem iterating in a jsp poeta_boy Programming 2 09-06-2005 02:36 PM
Cannot instantiate class from JSP Jose Muņiz Programming 2 07-19-2004 12:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration