Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a new Web application titled <yourname>Week6. Next, create a JSP that dis

ID: 3624248 • Letter: C

Question

Create a new Web application titled <yourname>Week6. Next, create a JSP that displays a form when the doGet method is invoked. The form will contain a post action that directs the form post back to the same JSP, which in the doPost method will save the form data to a database. Use your Oracle account to make the DB connection. After the form data has been saved to the database, respond back with a query from the database displaying all the current records contained in the database, in an appealing format. The form must contain a minimum of three input fields. The grade for this assignment will be based both on the functionality of the servlet and the appearance of the form post results. Name your JSP <yourName>FormPost3 and name the application <yourname>Week6. Create a Web archive file and submit along with assignment.

Explanation / Answer

 

Dear user,

 here is the code below:

import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

import java.sql.*;

public class MartinFormPost3 extends HttpServlet

{

public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException

{

res.setContentType("text/html");

String sn = req.getParameter("studentname");

String fn= req.getParameter("fathername");

String dbo = req.getParameter("dbo");

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbc");

Connection co =DriverManager.getConnection("jdbc:odbc:dsn","system","manager");

String sql="insert into data(sname,fname,dob)values(?,?,?)";

PreparedStatement p=co.prepareStatement(sql);

p.setString(1,sn);

p.setString(2,fn);

p.setString(3,dbo);

p.executeUpdate();

co.commit();

res.sendRedirect("ReenaWeek5.html");

}

catch (Exception e)

{

System.out.println(e);

}

}

public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException

{

doPost (req,res);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote