I am using jsp at ubuntu machine.
Using jdbc, I could access my own database without my own function.
I tried to gather all database facilities at one jsp file and just call those functions at other jsp files.
My tries are,
api/Login.jsp
<%@page import="java.sql.*"%>
<%!
public int CheckLogin(String login, String password)
{
// query database.
Class.forName("com.mysql.jdbc.Driver");
String myUrl = "jdbc:mysql://localhost/prjhd";
...
checkLogin.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="api/Login.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hyundai co-relation page</title>
</head>
<body>
<%
// get parameters.
String login=request.getParameter("login");
String password=request.getParameter("password");
int result=CheckLogin(login, password);
...
When atempting to access checkLogin.jsp, Exception error is occurred.
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the jsp file: /api/Login.jsp
Unhandled exception type ClassNotFoundException
3: public int CheckLogin(String login, String password)
4: {
5: // query database.
6: Class.forName("com.mysql.jdbc.Driver");
7: String myUrl = "jdbc:mysql://localhost/prjhd";
8: Connection conn = DriverManager.getConnection(myUrl,"prjhd","---");
9: String query = "select password from User where login=?";
I tried to search this issue, but I couldn't find proper answers. When I used Class.forName(...) at same jsp file, There is no problem. This problem was occurred when split jsp files and make a function.