Can I have a index.html in a maven project?

Viewed 29

I am new to Java and I have a Java application with Maven.

I have index.html file that opens a question to the user. If the user says "Yes" it opens another HTML file called form.html.

I created a file called insertData.java that connects with my DB.

However, when I click on my submit button on form.html it opens the insertData.java with my code and does not post the data on the DB.

Also, why in a Maven project when I try to run my project the index.html only has the option view?

When I try to run the project it goes to java file and not to my HTML file.

I changed my InsertData to JSP and now it does not add data on the DB.

    <%@page import="java.sql.SQLException"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<% 
//    java.lang.System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
    String fname = request.getParameter("fname");    
    String lname = request.getParameter("lname");
        
  
      
 String url = "jdbc:mysql://localhost:3306/test";
        String user = "root";
        String password = "root";
        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection connection = DriverManager.getConnection(url, user, password);
            System.out.println("Connection is Successful to the database" + url);
            String query =  "INSERT INTO test.student values (8,'ram8')";
            Statement statement = connection.createStatement();
            statement.execute(query);
        
           out.println(fname);


        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    %>
0 Answers
Related