Computer Science, asked by issh, 1 year ago

Develop a web page using servlet to display the details of teachers who are teaching the 5th semester courses of MCA program

Answers

Answered by ashishboehring
3
CREATE TABLE  "REGISTERUSER"      (    "NAME" VARCHAR2(4000),       "PASS" VARCHAR2(4000),       "EMAIL" VARCHAR2(4000),       "COUNTRY" VARCHAR2(4000)     )  /  
<html>  <body>  <form action="servlet/Register" method="post">    Name:<input type="text" name="userName"/><br/><br/>  Password:<input type="password" name="userPass"/><br/><br/>  Email Id:<input type="text" name="userEmail"/><br/><br/>  Country:  <select name="userCountry">  <option>India</option>  <option>Pakistan</option>  <option>other</option>  </select>  <br/><br/>  <input type="submit" value="register"/>    </form>  </body>  </html>  
import java.io.*;  import java.sql.*;  import javax.servlet.ServletException;  import javax.servlet.http.*;    public class Register extends HttpServlet {  public void doPost(HttpServletRequest request, HttpServletResponse response)              throws ServletException, IOException {    response.setContentType("text/html");  PrintWriter out = response.getWriter();            String n=request.getParameter("userName");  String p=request.getParameter("userPass");  String e=request.getParameter("userEmail");  String c=request.getParameter("userCountry");            try{  Class.forName("oracle.jdbc.driver.OracleDriver");  Connection con=DriverManager.getConnection(  "jdbc:oracle:thin:@localhost:1521:xe","system","oracle");    PreparedStatement ps=con.prepareStatement(  "insert into registeruser values(?,?,?,?)");    ps.setString(1,n);  ps.setString(2,p);  ps.setString(3,e);  ps.setString(4,c);            int i=ps.executeUpdate();  if(i>0)  out.print("You are successfully registered...");                  }catch (Exception e2) {System.out.println(e2);}            out.close();  }    }  web.xml file

The is the configuration file, providing information about the servlet.

<web-app>    <servlet>  <servlet-name>Register</servlet-name>  <servlet-class>Register</servlet-class>  </servlet>    <servlet-mapping>  <servlet-name>Register</servlet-name>  <url-pattern>/servlet/Register</url-pattern>  </servlet-mapping>    <welcome-file-list>      <welcome-file>register.html</welcome-file>  </welcome-file-list>    </web-app>  
Similar questions