So I've been tying to set up a database for an imaginary flight company. I'm supposed to have a JSP page that allows admins to enter data like flight number, flight model, capacity, seat layout etc into a database. I managed to allow the admin to enter data such as flight model and number into the database. However, I do not know how to let admins add an image of the seating layout into the database. More specifically, I need to let the admins browse their computers and upload an image file from their computer into my database, and store it there so that whenever user search for a particular plane mode, such as Boeing-747, the image of the seat layout for the Boeing-747 will be returned. Any ideas on how I can do that? Any and all help would be appreciated.
I've been trying to look for a solution on Google, but I have no idea how to add any of the codes that I have found into my codes. In case anyone is wondering what I've already done, this is what I have so far:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%@page import="java.sql.*"%>
<%@page import="java.io.*" %>
<%
String Model = request.getParameter("Model");
String Flight_number = request.getParameter("Flight_number");
Statement theStatement = null;
String capacity = request.getParameter("Capacity");
boolean x=true;
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url="jdbc:mysql://localhost/testing";
String username="root";
String password="password";
Connection conn=DriverManager.getConnection(url,username,password);
theStatement =(Statement)conn.createStatement();
theStatement.executeUpdate("INSERT INTO testing.aircraft_data ( aircraft_model, flight_no , passenger_capacity)"+ "VALUES ('"+Model+"' , '"+Flight_number+"' , '"+capacity+"')");
//Process Result
theStatement.close();
conn.close();
}
catch(Exception e){
out.println("Exception occured! "+e.getMessage()+" "+e.getStackTrace());
x=false;
out.println(e);
System.out.println(e);
response.sendRedirect("Homescreen_Admin.jsp?correct="+x+e);
}
//response.sendRedirect("Homescreen_Admin.jsp?correct="+x);
%>
</body>
</html>