0

Is there a way to store radio data from an HTML into MySQL using servlets? I have the correct APIs for servlets to communicate with MySQL, and my other projects seem to work except for this one.

enter image description here

The Error is:

"The origin server did not find a current representation for the target resource or is not willing to disclose that one exists."

I've already tried "Run as Server" but it still errors

Servlet code:

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.sql.*;


public class PostVote extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    
    public PostVote() {
        super();
        // TODO Auto-generated constructor stub
    }
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String name = request.getParameter("name");
    String subjects = request.getParameter("subjects");
    
    try {
        Class.forName("com.mysql.jdbc.Driver");
                                                    //default/port number def/database name/root/password
        Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/votetest","root","password");
        Statement st=con.createStatement();//Table name //table details //              //Values from HTML converted into SQL
        st.executeUpdate("insert into responsetbl (name,subjects) values('"+name+"','"+subjects+"')");
        response.sendRedirect("record_added.html");
        }
        
    catch(Exception e) {
        response.sendRedirect("failed.html");
    }   
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        
    }
    
}


0 Answers0